#include <ISO8583.h>
#include <Prot8583.h>
#include <aclutil.h>
#include <xmodem.h>

#include <stdlib.h>
#include <string.h>
#include <svc.h>
#include <svctxo.h>

//Include file for ACT2000
#include <applidl.h>
#include <acldev.h>
#include <aclstr.h>
#include <message.h>
#include <printer.h>
#include <power.h>

#include "UserIf.h"
#include "PobTran.h"
#include "uclcode.h"
#include "Comm.h"
#include "Msg.h"
#include "Pinpad.h"
#include "Display.txo"


TRANSACTION_OBJECT obTran;
struct	TRACK stParsedCardData ;	// Card Data Holder

extern short hCon;	// Console	 handle
extern short hPrinter;
extern short hMagReader;
extern COMM_OBJECT obCommunication;
extern char Iklan[1000];
int inDisplayResponseMode=0;
extern unsigned long lnModemTimer;
extern unsigned long lnBackLightTimer;

TRANSACTION_BITMAP obTranMap[] = {
	{PMT_TRX_PURCHASE	,1,0,0,0,"TRANSFER TO MERCHANT",  //for display in terminal (trx title) and in receipt
		"",									  //for receipt footer 1
		"",									  //for receipt footer 2
		"",
		"",
		"TRANSAKSI INI AKAN TERCATAT SEBAGAI",
		"TRANSFER DI BANK ANDA",
		"",
		"",
		"0200", "001200", "3020058020C01004", //Purchase of saving account, 002100 for current account
		"0400", "001200", "7024058000C00004", //Reversal
		"0000", "000000", "0000000000000000", //Void
		"0000", "000000", "0000000000000000", //Reversal of Void
		"0000", "000000", "0000000000000000"  //Advice
	},  
	{PMT_TRX_ISI_ULANG	,1,0,0,0,"ISI ULANG", 
		"Pulsa Otomatis Bertambah Untuk",
		"Simpati, Mentari, Pro-XL/Bebas,",
		"IM3, Esia, dan Fren",
		"",
		"Pulsa Otomatis Bertambah Untuk",
		"Simpati, Mentari, Pro-XL/Bebas,",
		"IM3, Esia, dan Fren",
		"",
		"0200", "501000", "3020058020C11004",	//isi ulang of saving acc, 502000 for current acc
		"0400", "501000", "7024058000C10004",
		"0000", "000000", "0000000000000000",
		"0000", "000000", "0000000000000000",
		"0000", "000000", "0000000000000000"
	},
	{PMT_TRX_REGISTRASI	,1,0,0,0,"REGISTRASI",
		"Anda Akan Menerima Konfirmasi Via SMS",
		"Ketik: TIN <Spasi> XY",
		"XY Adalah TIN Yang Akan Diminta dan",
		"Kirim ke 3399",
		"Anda Akan Menerima Konfirmasi Via SMS",
		"Ketik: TIN <Spasi> XY",
		"XY Adalah TIN Yang Akan Diminta dan",
		"Kirim ke 3399",
		"0200", "800001", "2020058020C11004",
		"0000", "000000", "0000000000000000",
		"0000", "000000", "0000000000000000",
		"0000", "000000", "0000000000000000",
		"0000", "000000", "0000000000000000"
	},
	{PMT_TRX_TIN		,1,0,0,0,"T I N",
		"",
		"",
		"",
		"",
		"",
		"",
		"",
		"",
		"0100", "980000", "2020058020C11004",
		"0000", "000000", "0000000000000000",
		"0000", "000000", "0000000000000000",
		"0000", "000000", "0000000000000000",
		"0000", "000000", "0000000000000000"
	},
	{PMT_TRX_INFO_SALDO	,1,0,0,0,"INFORMASI SALDO",  //for display in terminal (trx title) and in receipt
		"",									  //for receipt footer 1
		"",									  //for receipt footer 2
		"",
		"",
		"",
		"",
		"",
		"",
		"0200", "311100", "2020058020C01004", //saving account, 312100 for current account
		"0000", "000000", "0000000000000000", //Reversal
		"0000", "000000", "0000000000000000", //Void
		"0000", "000000", "0000000000000000", //Reversal of Void
		"0000", "000000", "0000000000000000"  //Advice
	},  
	{PMT_TRX_MINI_STATEMENT	,1,0,0,0,"MINI STATEMENT",  //for display in terminal (trx title) and in receipt
		"",									  //for receipt footer 1
		"",									  //for receipt footer 2
		"",
		"",
		"",
		"",
		"",
		"",
		"0200", "381100", "2020058020C01004", //saving account, 382100 for current account
		"0000", "000000", "0000000000000000", //Reversal
		"0000", "000000", "0000000000000000", //Void
		"0000", "000000", "0000000000000000", //Reversal of Void
		"0000", "000000", "0000000000000000"  //Advice
	},  
	{PMT_TRX_INFO_CDTCARD	,1,0,0,0,"INFO KARTU KREDIT",  //for display in terminal (trx title) and in receipt
		"",									  //for receipt footer 1
		"",									  //for receipt footer 2
		"",
		"",
		"",
		"",
		"",
		"",
		"0300", "393000", "2020058020C10004", 
		"0000", "000000", "0000000000000000", //Reversal
		"0000", "000000", "0000000000000000", //Void
		"0000", "000000", "0000000000000000", //Reversal of Void
		"0000", "000000", "0000000000000000"  //Advice
	},  
	{PMT_TRX_INFO_BILLING	,1,0,0,0,"INFO BILLING",  //for display in terminal (trx title) and in receipt
		"",									  //for receipt footer 1
		"",									  //for receipt footer 2
		"",
		"",
		"",
		"",
		"",
		"",
		"0300", "389900", "2020058020C11004", 
		"0000", "000000", "0000000000000000", //Reversal
		"0000", "000000", "0000000000000000", //Void
		"0000", "000000", "0000000000000000", //Reversal of Void
		"0000", "000000", "0000000000000000"  //Advice
	},  
	{PMT_TRX_INFO_NAME	,1,0,0,0,"INFO TARGET NAME",  //for display in terminal (trx title) and in receipt
		"",									  //for receipt footer 1
		"",									  //for receipt footer 2
		"",
		"",
		"",
		"",
		"",
		"",
		"0300", "390000", "2020058020C11004", 
		"0000", "000000", "0000000000000000", //Reversal
		"0000", "000000", "0000000000000000", //Void
		"0000", "000000", "0000000000000000", //Reversal of Void
		"0000", "000000", "0000000000000000"  //Advice
	},  
	{PMT_TRX_BAYAR_TELPON	,1,0,0,0,"PEMBAYARAN TELEPON",  //for display in terminal (trx title) and in receipt
		"Layanan Pembayaran Tagihan:",				 //for receipt footer 1
		"Telkom, Flexi, KartuHalo, Matrix",			 //for receipt footer 2
		"ProXL(XPLOR), IM3, Esia, Mobile8(Fren)",
		"",
		"Layanan Pembayaran Tagihan:",				 //for receipt footer 1
		"Telkom, Flexi, KartuHalo, Matrix",			 //for receipt footer 2
		"ProXL(XPLOR), IM3, Esia, Mobile8(Fren)",
		"",
		"0200", "501000", "3020058020C11004", //502000 for current acc
		"0400", "501000", "7024058000C10004", //Reversal
		"0000", "000000", "0000000000000000", //Void
		"0000", "000000", "0000000000000000", //Reversal of Void
		"0000", "000000", "0000000000000000"  //Advice
	},  
	{PMT_TRX_BAYAR_PLN ,1,0,0,0,"PEMBAYARAN PLN",  //for display in terminal (trx title) and in receipt
		"PLN MENYATAKAN STRUK INI SEBAGAI",									  //for receipt footer 1
		"BUKTI PEMBAYARAN YANG SAH",									  //for receipt footer 2
		"",
		"",
		"PLN MENYATAKAN STRUK INI SEBAGAI",									  //for receipt footer 1
		"BUKTI PEMBAYARAN YANG SAH",									  //for receipt footer 2
		"",
		"",
		"0200", "501000", "3020058020C11004", //502000 for current acc
		"0400", "501000", "7024058000C10004", //Reversal
		"0000", "000000", "0000000000000000", //Void
		"0000", "000000", "0000000000000000", //Reversal of Void
		"0000", "000000", "0000000000000000"  //Advice
	},  
	{PMT_TRX_BAYAR_PALYJA	,1,0,0,0,"PEMBAYARAN PALYJA",  //for display in terminal (trx title) and in receipt
		"PALYJA MENYATAKAN STRUK INI SEBAGAI",									  //for receipt footer 1
		"BUKTI PEMBAYARAN YANG SAH",									  //for receipt footer 2
		"",
		"",
		"PALYJA MENYATAKAN STRUK INI SEBAGAI",									  //for receipt footer 1
		"BUKTI PEMBAYARAN YANG SAH",									  //for receipt footer 2
		"",
		"",
		"0200", "501000", "3020058020C11004", //502000 for current acc
		"0400", "501000", "7024058000C10004", //Reversal
		"0000", "000000", "0000000000000000", //Void
		"0000", "000000", "0000000000000000", //Reversal of Void
		"0000", "000000", "0000000000000000"  //Advice
	},  
	{PMT_TRX_BAYAR_PAM	,1,0,0,0,"PEMBAYARAN PAM",  //for display in terminal (trx title) and in receipt
		"HARAP TANDA TERIMA INI DISIMPAN SEBAGAI",	 //for receipt footer 1
		"BUKTI PEMBAYARAN. SEGALA KESALAHAN",		 //for receipt footer 2
		"INPUT MENJADI TANGGUNG JAWAB NASABAH",
		"",
		"HARAP TANDA TERIMA INI DISIMPAN SEBAGAI",	 //for receipt footer 1
		"BUKTI PEMBAYARAN. SEGALA KESALAHAN",		 //for receipt footer 2
		"INPUT MENJADI TANGGUNG JAWAB NASABAH",
		"",
		"0200", "501000", "3020058020C11004", //502000 for current acc
		"0400", "501000", "7024058000C10004", //Reversal
		"0000", "000000", "0000000000000000", //Void
		"0000", "000000", "0000000000000000", //Reversal of Void
		"0000", "000000", "0000000000000000"  //Advice
	},  
	{PMT_TRX_BAYAR_CDTCARD	,1,0,0,0,"BAYAR KARTU KREDIT",  //for display in terminal (trx title) and in receipt
		"HARAP TANDA TERIMA INI DISIMPAN SEBAGAI",	 //for receipt footer 1
		"BUKTI PEMBAYARAN. SEGALA KESALAHAN",		 //for receipt footer 2
		"INPUT MENJADI TANGGUNG JAWAB NASABAH",
		"",
		"HARAP TANDA TERIMA INI DISIMPAN SEBAGAI",	 //for receipt footer 1
		"BUKTI PEMBAYARAN. SEGALA KESALAHAN",		 //for receipt footer 2
		"INPUT MENJADI TANGGUNG JAWAB NASABAH",
		"",
		"0200", "501000", "3020058020C11004", //502000 for current acc
		"0400", "501000", "7024058000C10004", //Reversal
		"0000", "000000", "0000000000000000", //Void
		"0000", "000000", "0000000000000000", //Reversal of Void
		"0000", "000000", "0000000000000000"  //Advice
	},  
	{PMT_TRX_CICILAN_ACC	,1,0,0,0,"CICILAN ACC",  //for display in terminal (trx title) and in receipt
		"HARAP TANDA TERIMA INI DISIMPAN SEBAGAI",	 //for receipt footer 1
		"BUKTI PEMBAYARAN. SEGALA KESALAHAN",		 //for receipt footer 2
		"INPUT MENJADI TANGGUNG JAWAB NASABAH",
		"",
		"HARAP TANDA TERIMA INI DISIMPAN SEBAGAI",	 //for receipt footer 1
		"BUKTI PEMBAYARAN. SEGALA KESALAHAN",		 //for receipt footer 2
		"INPUT MENJADI TANGGUNG JAWAB NASABAH",
		"",
		"0200", "501000", "3020058020C11004", //502000 for current acc
		"0400", "501000", "7024058000C10004", //Reversal
		"0000", "000000", "0000000000000000", //Void
		"0000", "000000", "0000000000000000", //Reversal of Void
		"0000", "000000", "0000000000000000"  //Advice
	},  
	{PMT_TRX_CICILAN_FIF	,1,0,0,0,"CICILAN FIF",  //for display in terminal (trx title) and in receipt
		"HARAP TANDA TERIMA INI DISIMPAN SEBAGAI",	 //for receipt footer 1
		"BUKTI PEMBAYARAN. SEGALA KESALAHAN",		 //for receipt footer 2
		"INPUT MENJADI TANGGUNG JAWAB NASABAH",
		"",
		"HARAP TANDA TERIMA INI DISIMPAN SEBAGAI",	 //for receipt footer 1
		"BUKTI PEMBAYARAN. SEGALA KESALAHAN",		 //for receipt footer 2
		"INPUT MENJADI TANGGUNG JAWAB NASABAH",
		"",
		"0200", "501000", "3020058020C11004", //502000 for current acc
		"0400", "501000", "7024058000C10004", //Reversal
		"0000", "000000", "0000000000000000", //Void
		"0000", "000000", "0000000000000000", //Reversal of Void
		"0000", "000000", "0000000000000000"  //Advice
	},  

	{PMT_TRX_CICILAN_SCB	,1,0,0,0,"PERSONAL LOAN",  //for display in terminal (trx title) and in receipt
		"HARAP TANDA TERIMA INI DISIMPAN SEBAGAI",	 //for receipt footer 1
		"BUKTI PEMBAYARAN. SEGALA KESALAHAN",		 //for receipt footer 2
		"INPUT MENJADI TANGGUNG JAWAB NASABAH",
		"",
		"HARAP TANDA TERIMA INI DISIMPAN SEBAGAI",	 //for receipt footer 1
		"BUKTI PEMBAYARAN. SEGALA KESALAHAN",		 //for receipt footer 2
		"INPUT MENJADI TANGGUNG JAWAB NASABAH",
		"",
		"0200", "501000", "3020058020C11004", //502000 for current acc
		"0400", "501000", "7024058000C10004", //Reversal
		"0000", "000000", "0000000000000000", //Void
		"0000", "000000", "0000000000000000", //Reversal of Void
		"0000", "000000", "0000000000000000"  //Advice
	},  

	{PMT_TRX_CICILAN_CITI	,1,0,0,0,"CICILAN CITI",  //for display in terminal (trx title) and in receipt
		"HARAP TANDA TERIMA INI DISIMPAN SEBAGAI",	 //for receipt footer 1
		"BUKTI PEMBAYARAN. SEGALA KESALAHAN",		 //for receipt footer 2
		"INPUT MENJADI TANGGUNG JAWAB NASABAH",
		"",
		"HARAP TANDA TERIMA INI DISIMPAN SEBAGAI",	 //for receipt footer 1
		"BUKTI PEMBAYARAN. SEGALA KESALAHAN",		 //for receipt footer 2
		"INPUT MENJADI TANGGUNG JAWAB NASABAH",
		"",
		"0200", "501000", "3020058020C11004", //502000 for current acc
		"0400", "501000", "7024058000C10004", //Reversal
		"0000", "000000", "0000000000000000", //Void
		"0000", "000000", "0000000000000000", //Reversal of Void
		"0000", "000000", "0000000000000000"  //Advice
	},  

	{PMT_TRX_CICILAN_ADIRA	,1,0,0,0,"CICILAN ADIRA",  //for display in terminal (trx title) and in receipt
		"HARAP TANDA TERIMA INI DISIMPAN SEBAGAI",	 //for receipt footer 1
		"BUKTI PEMBAYARAN. SEGALA KESALAHAN",		 //for receipt footer 2
		"INPUT MENJADI TANGGUNG JAWAB NASABAH",
		"",
		"HARAP TANDA TERIMA INI DISIMPAN SEBAGAI",	 //for receipt footer 1
		"BUKTI PEMBAYARAN. SEGALA KESALAHAN",		 //for receipt footer 2
		"INPUT MENJADI TANGGUNG JAWAB NASABAH",
		"",
		"0200", "501000", "3020058020C11004", //502000 for current acc
		"0400", "501000", "7024058000C10004", //Reversal
		"0000", "000000", "0000000000000000", //Void
		"0000", "000000", "0000000000000000", //Reversal of Void
		"0000", "000000", "0000000000000000"  //Advice
	},  

	{PMT_TRX_BAYAR_PENDIDIKAN	,1,0,0,0,"BAYAR PENDIDIKAN",  //for display in terminal (trx title) and in receipt
		"HARAP TANDA TERIMA INI DISIMPAN SEBAGAI",	 //for receipt footer 1
		"BUKTI PEMBAYARAN. SEGALA KESALAHAN",		 //for receipt footer 2
		"INPUT MENJADI TANGGUNG JAWAB NASABAH",
		"",
		"HARAP TANDA TERIMA INI DISIMPAN SEBAGAI",	 //for receipt footer 1
		"BUKTI PEMBAYARAN. SEGALA KESALAHAN",		 //for receipt footer 2
		"INPUT MENJADI TANGGUNG JAWAB NASABAH",
		"",
		"0200", "501000", "3020058020C11004", //502000 for current acc
		"0400", "501000", "7024058000C10004", //Reversal
		"0000", "000000", "0000000000000000", //Void
		"0000", "000000", "0000000000000000", //Reversal of Void
		"0000", "000000", "0000000000000000"  //Advice
	},  
	{PMT_TRX_BAYAR_ASURANSI	,1,0,0,0,"BAYAR ASURANSI",  //for display in terminal (trx title) and in receipt
		"HARAP TANDA TERIMA INI DISIMPAN SEBAGAI",	 //for receipt footer 1
		"BUKTI PEMBAYARAN. SEGALA KESALAHAN",		 //for receipt footer 2
		"INPUT MENJADI TANGGUNG JAWAB NASABAH",
		"",
		"HARAP TANDA TERIMA INI DISIMPAN SEBAGAI",	 //for receipt footer 1
		"BUKTI PEMBAYARAN. SEGALA KESALAHAN",		 //for receipt footer 2
		"INPUT MENJADI TANGGUNG JAWAB NASABAH",
		"",
		"0200", "501000", "3020058020C11004", //502000 for current acc
		"0400", "501000", "7024058000C10004", //Reversal
		"0000", "000000", "0000000000000000", //Void
		"0000", "000000", "0000000000000000", //Reversal of Void
		"0000", "000000", "0000000000000000"  //Advice
	},  
	{PMT_TRX_BAYAR_PAYID	,1,0,0,0,"PEMBAYARAN PAY ID",  //for display in terminal (trx title) and in receipt
		"HARAP TANDA TERIMA INI DISIMPAN SEBAGAI",	 //for receipt footer 1
		"BUKTI PEMBAYARAN. SEGALA KESALAHAN",		 //for receipt footer 2
		"INPUT MENJADI TANGGUNG JAWAB NASABAH",
		"",
		"HARAP TANDA TERIMA INI DISIMPAN SEBAGAI",	 //for receipt footer 1
		"BUKTI PEMBAYARAN. SEGALA KESALAHAN",		 //for receipt footer 2
		"INPUT MENJADI TANGGUNG JAWAB NASABAH",
		"",
		"0200", "501000", "3020058020C11004", //502000 for current acc
		"0400", "501000", "7024058000C10004", //Reversal
		"0000", "000000", "0000000000000000", //Void
		"0000", "000000", "0000000000000000", //Reversal of Void
		"0000", "000000", "0000000000000000"  //Advice
	},  
	{PMT_TRX_TRANSFER	,1,0,0,0,"TRANSFER TO OWN ACC",  //for display in terminal (trx title) and in receipt
		"SIMPANLAH STRUK INI SEBAGAI BUKTI", //for receipt footer 1
		"TRANSFER. SEGALA KESALAHAN INPUT",	  //for receipt footer 2
		"MENJADI TANGGUNG JAWAB NASABAH",
		"",
		"SIMPANLAH STRUK INI SEBAGAI BUKTI", //for receipt footer 1
		"TRANSFER. SEGALA KESALAHAN INPUT",	  //for receipt footer 2
		"MENJADI TANGGUNG JAWAB NASABAH",
		"",
		"0200", "401008", "3020058020C11004", //saving account, 402008 for current account
		"0400", "401008", "7024058000C10004", //Reversal
		"0000", "000000", "0000000000000000", //Void
		"0000", "000000", "0000000000000000", //Reversal of Void
		"0000", "000000", "0000000000000000"  //Advice
	},  
	{PMT_TRX_TRANSFER_REK_LAIN	,1,0,0,0,"TRANSFER TO PERMATA",  //for display in terminal (trx title) and in receipt
		"SIMPANLAH STRUK INI SEBAGAI BUKTI", //for receipt footer 1
		"TRANSFER. SEGALA KESALAHAN INPUT",	  //for receipt footer 2
		"MENJADI TANGGUNG JAWAB NASABAH",
		"",
		"SIMPANLAH STRUK INI SEBAGAI BUKTI", //for receipt footer 1
		"TRANSFER. SEGALA KESALAHAN INPUT",	  //for receipt footer 2
		"MENJADI TANGGUNG JAWAB NASABAH",
		"",
		"0200", "401008", "3020058020C11004", //saving account, 402008 for current account
		"0400", "401008", "7024058000C10004", //Reversal
		"0000", "000000", "0000000000000000", //Void
		"0000", "000000", "0000000000000000", //Reversal of Void
		"0000", "000000", "0000000000000000"  //Advice
	},  
	{PMT_TRX_TRANSFER_BANK_LAIN	,1,0,0,0,"TRANSFER ONLINE",  //for display in terminal (trx title) and in receipt
		"SIMPANLAH STRUK INI SEBAGAI BUKTI", //for receipt footer 1
		"TRANSFER. SEGALA KESALAHAN INPUT",	  //for receipt footer 2
		"MENJADI TANGGUNG JAWAB NASABAH",
		"",
		"SIMPANLAH STRUK INI SEBAGAI BUKTI", //for receipt footer 1
		"TRANSFER. SEGALA KESALAHAN INPUT",	  //for receipt footer 2
		"MENJADI TANGGUNG JAWAB NASABAH",
		"",
		"0200", "491009", "3020058020C11004", //saving account, 402008 for current account
		"0400", "491009", "7024058000C10004", //Reversal
		"0000", "000000", "0000000000000000", //Void
		"0000", "000000", "0000000000000000", //Reversal of Void
		"0000", "000000", "0000000000000000"  //Advice
	},  
	{PMT_TRX_PIN_CHANGE	,1,0,0,0,"PIN CHANGE",  //for display in terminal (trx title) and in receipt
		"",									  //for receipt footer 1
		"",									  //for receipt footer 2
		"",
		"",
		"",
		"",
		"",
		"",
		"0100", "980100", "2020058020C11004", //PIN Change
		"0000", "000000", "0000000000000000", //Reversal
		"0000", "000000", "0000000000000000", //Void
		"0000", "000000", "0000000000000000", //Reversal of Void
		"0000", "000000", "0000000000000000"  //Advice
	},  
	{PMT_TRX_BELANJA_POIN	,1,0,0,0,"BELANJA POIN",  //for display in terminal (trx title) and in receipt
		"",									  //for receipt footer 1
		"",									  //for receipt footer 2
		"",
		"",
		"",
		"",
		"",
		"",
		"0200", "311100", "2020058020C01004", //saving account, 312100 for current account
		"0000", "000000", "0000000000000000", //Reversal
		"0000", "000000", "0000000000000000", //Void
		"0000", "000000", "0000000000000000", //Reversal of Void
		"0000", "000000", "0000000000000000"  //Advice
	},
	{PMT_TRX_BAYAR_TIKET	,1,0,0,0,"BAYAR TIKET",  //for display in terminal (trx title) and in receipt
		"TERIMA INI SEBAGAI BUKTI UNTUK",			//for receipt footer 1
		"PENUKARAN TIKET DI AIRPORT",				//for receipt footer 2
		"ATAU UNTUK KANTOR PENJUALAN GARUDA",
		"",
		"TERIMA INI SEBAGAI BUKTI UNTUK",			//for receipt footer 1
		"PENUKARAN TIKET DI AIRPORT",				//for receipt footer 2
		"ATAU UNTUK KANTOR PENJUALAN GARUDA",
		"",
		"0200", "501000", "3020058020C11004", //502000 for current acc
		"0400", "501000", "7024058000C10004", //Reversal
		"0000", "000000", "0000000000000000", //Void
		"0000", "000000", "0000000000000000", //Reversal of Void
		"0000", "000000", "0000000000000000"  //Advice
	},
	{PMT_TRX_CICILAN_TAF	,1,0,0,0,"CICILAN TA FINANCE",  //for display in terminal (trx title) and in receipt
		"HARAP TANDA TERIMA INI DISIMPAN SEBAGAI",	 //for receipt footer 1
		"BUKTI PEMBAYARAN YANG SAH", 
		"SEGALA KESALAHAN INPUT MENJADI",		 //for receipt footer 2
		"TANGGUNG JAWAB NASABAH",
		
		"HARAP TANDA TERIMA INI DISIMPAN SEBAGAI",	 //for receipt footer 1
		"BUKTI PEMBAYARAN YANG SAH", 
		"SEGALA KESALAHAN INPUT MENJADI",		 //for receipt footer 2
		"TANGGUNG JAWAB NASABAH",
		
		"0200", "501000", "3020058020C11004", //502000 for current acc
		"0400", "501000", "7024058000C10004", //Reversal
		"0000", "000000", "0000000000000000", //Void
		"0000", "000000", "0000000000000000", //Reversal of Void
		"0000", "000000", "0000000000000000"  //Advice
	}


/*
	{TRX_INFO_SALDO			, "0100", "300000", "2020058020C01000", 0, 0,0,0,"Info Saldo"}, //void & reversal should be based on this info only
	{TRX_PRE_TRANSFER		, "0100", "400000", "3020058020C01010", 1, 0,0,0,"Pra Transfer Dana"},
	{TRX_TRANSFER			, "0200", "400000", "3020058020C01014", 1, 0,0,0,"Transfer Dana"},
	{TRX_PAY_CC_STD			, "0200", "500000", "3020058020C01014", 1, 0,0,0,"Bayar K.Kredit"},
	{TRX_PRE_PAY_PLN		, "0100", "600000", "2020058020C01010", 1, 0,0,0,"Pra Bayar PLN"},
	{TRX_PAY_PLN			, "0200", "600000", "3020058020C01014", 1, 0,0,0,"Bayar PLN"},
	{TRX_PAY_PAM			, "0200", "000000", "3020058020C00000", 1, 0,0,0,"Bayar Tag. PAM"},
	{TRX_PRE_PAY_LLPHONE_STD, "0100", "700000", "2020058020C01010", 1, 0,0,0,"Pre-Bayar Telpon"},
	{TRX_PAY_LLPHONE_STD	, "0200", "700000", "3020058020C01014", 1, 0,0,0,"Bayar Telpon"},
	{TRX_PAY_HPHONE_STD		, "0200", "800000", "3020058020C01014", 1, 0,0,0,"Bayar Handphone"},
	{TRX_TOPUP_STD			, "0200", "900000", "3020058020C01014", 1, 0,0,0,"Topup Handphone"},
	{TRX_BUY_VOUCHERHP_STD	, "0200", "100000", "3020058020C01014", 1, 0,0,0,"Beli Voucher HP"},
	{TRX_MINI_STATEMENT		, "0200", "000000", "3020058020C00000", 1, 0,0,0,"Mini Statement"},
	{TRX_REGISTRASI_MB		, "0300", "100000", "2020058020C01010", 1, 0,0,0,"Registrasi MB"},
	{TRX_PIN_CHANGE			, "0300", "200000", "2020058020C11000", 1, 0,0,0,"Change PIN"},
	{TRX_TIN_CREATE			, "0300", "300000", "2020058020C11000", 1, 0,0,0,"Create TIN"},

	{TRX_CREDIT_POINT			, "0200", "000000", "3020058020C00004", 1, 0,0,0,"Tambah Point"},
	{TRX_CREDIT_POINT_OFFLINE   , "0220", "000000", "3020058024C00004", 1, 0,0,0,"Offline Point"},
	{TRX_DEBET_POINT			, "0200", "100000", "3020058020C01004", 1, 0,0,0,"Kurang Point"},
	{TRX_INFO_POINT				, "0100", "300000", "2020058020C00000", 1, 0,0,0,"Info Saldo Point"},
*/
};

int obTranMapCount = sizeof(obTranMap)/sizeof(TRANSACTION_BITMAP);

int inSetFooterText(char *szDest, char *szID)
{
	char buff[128];
	memset(buff, 0x00, sizeof(buff));
	get_env(szID, buff, sizeof(buff)-1);
	vdTrimSpace(buff);
	buff[42] = 0x00;
	strcpy(szDest, buff);
	return 1;
}

int inInitConfig()
{
    int i=0;
	char buff[129];

	LOG_PRINTFF((0x08L, "Initialisasi Config..."));

	memset(buff, 0x00, sizeof(buff));                    //renumbering UCL_COMM
	get_env_x(UCL_COMM, 0, buff);
	if (atoi(buff)==0) put_env(UCL_COMM, "8", 1);

	memset(buff, 0x00, sizeof(buff));
	get_env_x(TRX_MANUAL, 0, buff);       //if manual not allowed, turn off all manual entry
	if (buff[0]=='0'){ 
		for (i=0; i<obTranMapCount; i++) {
			obTranMap[i].inManual = 0;
		}
	}
	{//Power Save Management
		memset(buff, 0x00, sizeof(buff));
		get_env_x(POWERSAVE, 0, buff);
		lnBackLightTimer = atol(buff) * 1000L;
		if (lnBackLightTimer>0 && lnBackLightTimer<120000L){
			lnBackLightTimer = 120000L;
		}

		memset(buff, 0x00, sizeof(buff));
		get_env_x(POWERSAVE, 1, buff);
		if (atol(buff)==0L) {
			lnModemTimer = 0L;
		} else {
			lnModemTimer = (atol(buff) * 1000L) + lnBackLightTimer;
		}

		memset(buff, 0x00, sizeof(buff));
		get_env_x(POWERSAVE, 2, buff);
		if (strlen(buff)==0) {
			strcpy(buff, "3000");
		} else {
			strcat(buff, "000");
		}
		put_env("*POW", buff, strlen(buff));

		memset(buff, 0x00, sizeof(buff));
		get_env_x(POWERSAVE, 3, buff);
		if (strlen(buff)==0) {
			strcpy(buff, "120");	
		} 
		put_env("*OFF", buff, strlen(buff));
	}

	inSetFooterText(obTranMap[0].szFooter1, PRT_PURCHASE_FOOTER1);
	inSetFooterText(obTranMap[0].szFooter2, PRT_PURCHASE_FOOTER2);
	inSetFooterText(obTranMap[0].szFooter3, PRT_PURCHASE_FOOTER3);
	inSetFooterText(obTranMap[0].szFooter4, PRT_PURCHASE_FOOTER4);
	inSetFooterText(obTranMap[0].szFooter1B, PRT_PURCHASE_FOOTER1B);
	inSetFooterText(obTranMap[0].szFooter2B, PRT_PURCHASE_FOOTER2B);
	inSetFooterText(obTranMap[0].szFooter3B, PRT_PURCHASE_FOOTER3B);
	inSetFooterText(obTranMap[0].szFooter4B, PRT_PURCHASE_FOOTER4B);

	inSetFooterText(obTranMap[1].szFooter1, PRT_IU_FOOTER1);
	inSetFooterText(obTranMap[1].szFooter2, PRT_IU_FOOTER2);
	inSetFooterText(obTranMap[1].szFooter3, PRT_IU_FOOTER3);
	inSetFooterText(obTranMap[1].szFooter4, PRT_IU_FOOTER4);
	inSetFooterText(obTranMap[1].szFooter1B, PRT_IU_FOOTER1B);
	inSetFooterText(obTranMap[1].szFooter2B, PRT_IU_FOOTER2B);
	inSetFooterText(obTranMap[1].szFooter3B, PRT_IU_FOOTER3B);
	inSetFooterText(obTranMap[1].szFooter4B, PRT_IU_FOOTER4B);

	inSetFooterText(obTranMap[2].szFooter1, PRT_REG_FOOTER1);
	inSetFooterText(obTranMap[2].szFooter2, PRT_REG_FOOTER2);
	inSetFooterText(obTranMap[2].szFooter3, PRT_REG_FOOTER3);
	inSetFooterText(obTranMap[2].szFooter4, PRT_REG_FOOTER4);
	inSetFooterText(obTranMap[2].szFooter1B, PRT_REG_FOOTER1B);
	inSetFooterText(obTranMap[2].szFooter2B, PRT_REG_FOOTER2B);
	inSetFooterText(obTranMap[2].szFooter3B, PRT_REG_FOOTER3B);
	inSetFooterText(obTranMap[2].szFooter4B, PRT_REG_FOOTER4B);

	inSetFooterText(obTranMap[5].szFooter1, PRT_MINI_STATEMENT_F1);
	inSetFooterText(obTranMap[5].szFooter2, PRT_MINI_STATEMENT_F2);
	inSetFooterText(obTranMap[5].szFooter3, PRT_MINI_STATEMENT_F3);
	inSetFooterText(obTranMap[5].szFooter4, PRT_MINI_STATEMENT_F4);
	inSetFooterText(obTranMap[5].szFooter1B, PRT_MINI_STATEMENT_F1B);
	inSetFooterText(obTranMap[5].szFooter2B, PRT_MINI_STATEMENT_F2B);
	inSetFooterText(obTranMap[5].szFooter3B, PRT_MINI_STATEMENT_F3B);
	inSetFooterText(obTranMap[5].szFooter4B, PRT_MINI_STATEMENT_F4B);

	inSetFooterText(obTranMap[9].szFooter1, PRT_BAYAR_TELPON_F1);
	inSetFooterText(obTranMap[9].szFooter2, PRT_BAYAR_TELPON_F2);
	inSetFooterText(obTranMap[9].szFooter3, PRT_BAYAR_TELPON_F3);
	inSetFooterText(obTranMap[9].szFooter4, PRT_BAYAR_TELPON_F4);
	inSetFooterText(obTranMap[9].szFooter1B, PRT_BAYAR_TELPON_F1B);
	inSetFooterText(obTranMap[9].szFooter2B, PRT_BAYAR_TELPON_F2B);
	inSetFooterText(obTranMap[9].szFooter3B, PRT_BAYAR_TELPON_F3B);
	inSetFooterText(obTranMap[9].szFooter4B, PRT_BAYAR_TELPON_F4B);

	inSetFooterText(obTranMap[10].szFooter1, PRT_BAYAR_PLN_F1);
	inSetFooterText(obTranMap[10].szFooter2, PRT_BAYAR_PLN_F2);
	inSetFooterText(obTranMap[10].szFooter3, PRT_BAYAR_PLN_F3);
	inSetFooterText(obTranMap[10].szFooter4, PRT_BAYAR_PLN_F4);
	inSetFooterText(obTranMap[10].szFooter1B, PRT_BAYAR_PLN_F1B);
	inSetFooterText(obTranMap[10].szFooter2B, PRT_BAYAR_PLN_F2B);
	inSetFooterText(obTranMap[10].szFooter3B, PRT_BAYAR_PLN_F3B);
	inSetFooterText(obTranMap[10].szFooter4B, PRT_BAYAR_PLN_F4B);

	inSetFooterText(obTranMap[11].szFooter1, PRT_BAYAR_PALYJA_F1);
	inSetFooterText(obTranMap[11].szFooter2, PRT_BAYAR_PALYJA_F2);
	inSetFooterText(obTranMap[11].szFooter3, PRT_BAYAR_PALYJA_F3);
	inSetFooterText(obTranMap[11].szFooter4, PRT_BAYAR_PALYJA_F4);
	inSetFooterText(obTranMap[11].szFooter1B, PRT_BAYAR_PALYJA_F1B);
	inSetFooterText(obTranMap[11].szFooter2B, PRT_BAYAR_PALYJA_F2B);
	inSetFooterText(obTranMap[11].szFooter3B, PRT_BAYAR_PALYJA_F3B);
	inSetFooterText(obTranMap[11].szFooter4B, PRT_BAYAR_PALYJA_F4B);

	inSetFooterText(obTranMap[12].szFooter1, PRT_BAYAR_PAM_F1);
	inSetFooterText(obTranMap[12].szFooter2, PRT_BAYAR_PAM_F2);
	inSetFooterText(obTranMap[12].szFooter3, PRT_BAYAR_PAM_F3);
	inSetFooterText(obTranMap[12].szFooter4, PRT_BAYAR_PAM_F4);
	inSetFooterText(obTranMap[12].szFooter1B, PRT_BAYAR_PAM_F1B);
	inSetFooterText(obTranMap[12].szFooter2B, PRT_BAYAR_PAM_F2B);
	inSetFooterText(obTranMap[12].szFooter3B, PRT_BAYAR_PAM_F3B);
	inSetFooterText(obTranMap[12].szFooter4B, PRT_BAYAR_PAM_F4B);

	inSetFooterText(obTranMap[13].szFooter1, PRT_BAYAR_CDTCD_F1);
	inSetFooterText(obTranMap[13].szFooter2, PRT_BAYAR_CDTCD_F2);
	inSetFooterText(obTranMap[13].szFooter3, PRT_BAYAR_CDTCD_F3);
	inSetFooterText(obTranMap[13].szFooter4, PRT_BAYAR_CDTCD_F4);
	inSetFooterText(obTranMap[13].szFooter1B, PRT_BAYAR_CDTCD_F1B);
	inSetFooterText(obTranMap[13].szFooter2B, PRT_BAYAR_CDTCD_F2B);
	inSetFooterText(obTranMap[13].szFooter3B, PRT_BAYAR_CDTCD_F3B);
	inSetFooterText(obTranMap[13].szFooter4B, PRT_BAYAR_CDTCD_F4B);

	inSetFooterText(obTranMap[14].szFooter1, PRT_BAYAR_ACC_F1);
	inSetFooterText(obTranMap[14].szFooter2, PRT_BAYAR_ACC_F2);
	inSetFooterText(obTranMap[14].szFooter3, PRT_BAYAR_ACC_F3);
	inSetFooterText(obTranMap[14].szFooter4, PRT_BAYAR_ACC_F4);
	inSetFooterText(obTranMap[14].szFooter1B, PRT_BAYAR_ACC_F1B);
	inSetFooterText(obTranMap[14].szFooter2B, PRT_BAYAR_ACC_F2B);
	inSetFooterText(obTranMap[14].szFooter3B, PRT_BAYAR_ACC_F3B);
	inSetFooterText(obTranMap[14].szFooter4B, PRT_BAYAR_ACC_F4B);

	inSetFooterText(obTranMap[15].szFooter1, PRT_BAYAR_FIF_F1);
	inSetFooterText(obTranMap[15].szFooter2, PRT_BAYAR_FIF_F2);
	inSetFooterText(obTranMap[15].szFooter3, PRT_BAYAR_FIF_F3);
	inSetFooterText(obTranMap[15].szFooter4, PRT_BAYAR_FIF_F4);
	inSetFooterText(obTranMap[15].szFooter1B, PRT_BAYAR_FIF_F1B);
	inSetFooterText(obTranMap[15].szFooter2B, PRT_BAYAR_FIF_F2B);
	inSetFooterText(obTranMap[15].szFooter3B, PRT_BAYAR_FIF_F3B);
	inSetFooterText(obTranMap[15].szFooter4B, PRT_BAYAR_FIF_F4B);

	inSetFooterText(obTranMap[26].szFooter1, PRT_BAYAR_FIF_F1);
	inSetFooterText(obTranMap[26].szFooter2, PRT_BAYAR_FIF_F2);
	inSetFooterText(obTranMap[26].szFooter3, PRT_BAYAR_FIF_F3);
	inSetFooterText(obTranMap[26].szFooter4, PRT_BAYAR_FIF_F4);
	inSetFooterText(obTranMap[26].szFooter1B, PRT_BAYAR_FIF_F1B);
	inSetFooterText(obTranMap[26].szFooter2B, PRT_BAYAR_FIF_F2B);
	inSetFooterText(obTranMap[26].szFooter3B, PRT_BAYAR_FIF_F3B);
	inSetFooterText(obTranMap[26].szFooter4B, PRT_BAYAR_FIF_F4B);

	inSetFooterText(obTranMap[16].szFooter1, PRT_BAYAR_SCB_F1);
	inSetFooterText(obTranMap[16].szFooter2, PRT_BAYAR_SCB_F2);
	inSetFooterText(obTranMap[16].szFooter3, PRT_BAYAR_SCB_F3);
	inSetFooterText(obTranMap[16].szFooter4, PRT_BAYAR_SCB_F4);
	inSetFooterText(obTranMap[16].szFooter1B, PRT_BAYAR_SCB_F1B);
	inSetFooterText(obTranMap[16].szFooter2B, PRT_BAYAR_SCB_F2B);
	inSetFooterText(obTranMap[16].szFooter3B, PRT_BAYAR_SCB_F3B);
	inSetFooterText(obTranMap[16].szFooter4B, PRT_BAYAR_SCB_F4B);

	inSetFooterText(obTranMap[17].szFooter1, PRT_BAYAR_CITI_F1);
	inSetFooterText(obTranMap[17].szFooter2, PRT_BAYAR_CITI_F2);
	inSetFooterText(obTranMap[17].szFooter3, PRT_BAYAR_CITI_F3);
	inSetFooterText(obTranMap[17].szFooter4, PRT_BAYAR_CITI_F4);
	inSetFooterText(obTranMap[17].szFooter1B, PRT_BAYAR_CITI_F1B);
	inSetFooterText(obTranMap[17].szFooter2B, PRT_BAYAR_CITI_F2B);
	inSetFooterText(obTranMap[17].szFooter3B, PRT_BAYAR_CITI_F3B);
	inSetFooterText(obTranMap[17].szFooter4B, PRT_BAYAR_CITI_F4B);

	inSetFooterText(obTranMap[18].szFooter1, PRT_BAYAR_ADIRA_F1);
	inSetFooterText(obTranMap[18].szFooter2, PRT_BAYAR_ADIRA_F2);
	inSetFooterText(obTranMap[18].szFooter3, PRT_BAYAR_ADIRA_F3);
	inSetFooterText(obTranMap[18].szFooter4, PRT_BAYAR_ADIRA_F4);
	inSetFooterText(obTranMap[18].szFooter1B, PRT_BAYAR_ADIRA_F1B);
	inSetFooterText(obTranMap[18].szFooter2B, PRT_BAYAR_ADIRA_F2B);
	inSetFooterText(obTranMap[18].szFooter3B, PRT_BAYAR_ADIRA_F3B);
	inSetFooterText(obTranMap[18].szFooter4B, PRT_BAYAR_ADIRA_F4B);

	inSetFooterText(obTranMap[19].szFooter1, PRT_BAYAR_PDDKN_F1);
	inSetFooterText(obTranMap[19].szFooter2, PRT_BAYAR_PDDKN_F2);
	inSetFooterText(obTranMap[19].szFooter3, PRT_BAYAR_PDDKN_F3);
	inSetFooterText(obTranMap[19].szFooter4, PRT_BAYAR_PDDKN_F4);
	inSetFooterText(obTranMap[19].szFooter1B, PRT_BAYAR_PDDKN_F1B);
	inSetFooterText(obTranMap[19].szFooter2B, PRT_BAYAR_PDDKN_F2B);
	inSetFooterText(obTranMap[19].szFooter3B, PRT_BAYAR_PDDKN_F3B);
	inSetFooterText(obTranMap[19].szFooter4B, PRT_BAYAR_PDDKN_F4B);

	inSetFooterText(obTranMap[20].szFooter1, PRT_BAYAR_ASURANSI_F1);
	inSetFooterText(obTranMap[20].szFooter2, PRT_BAYAR_ASURANSI_F2);
	inSetFooterText(obTranMap[20].szFooter3, PRT_BAYAR_ASURANSI_F3);
	inSetFooterText(obTranMap[20].szFooter4, PRT_BAYAR_ASURANSI_F4);
	inSetFooterText(obTranMap[20].szFooter1B, PRT_BAYAR_ASURANSI_F1B);
	inSetFooterText(obTranMap[20].szFooter2B, PRT_BAYAR_ASURANSI_F2B);
	inSetFooterText(obTranMap[20].szFooter3B, PRT_BAYAR_ASURANSI_F3B);
	inSetFooterText(obTranMap[20].szFooter4B, PRT_BAYAR_ASURANSI_F4B);

	inSetFooterText(obTranMap[21].szFooter1, PRT_BAYAR_PAYID_F1);
	inSetFooterText(obTranMap[21].szFooter2, PRT_BAYAR_PAYID_F2);
	inSetFooterText(obTranMap[21].szFooter3, PRT_BAYAR_PAYID_F3);
	inSetFooterText(obTranMap[21].szFooter4, PRT_BAYAR_PAYID_F4);
	inSetFooterText(obTranMap[21].szFooter1B, PRT_BAYAR_PAYID_F1B);
	inSetFooterText(obTranMap[21].szFooter2B, PRT_BAYAR_PAYID_F2B);
	inSetFooterText(obTranMap[21].szFooter3B, PRT_BAYAR_PAYID_F3B);
	inSetFooterText(obTranMap[21].szFooter4B, PRT_BAYAR_PAYID_F4B);

	inSetFooterText(obTranMap[22].szFooter1, PRT_TR_F1);
	inSetFooterText(obTranMap[22].szFooter2, PRT_TR_F2);
	inSetFooterText(obTranMap[22].szFooter3, PRT_TR_F3);
	inSetFooterText(obTranMap[22].szFooter4, PRT_TR_F4);
	inSetFooterText(obTranMap[22].szFooter1B, PRT_TR_F1B);
	inSetFooterText(obTranMap[22].szFooter2B, PRT_TR_F2B);
	inSetFooterText(obTranMap[22].szFooter3B, PRT_TR_F3B);
	inSetFooterText(obTranMap[22].szFooter4B, PRT_TR_F4B);

	inSetFooterText(obTranMap[23].szFooter1, PRT_TF_OTHER_F1);
	inSetFooterText(obTranMap[23].szFooter2, PRT_TF_OTHER_F2);
	inSetFooterText(obTranMap[23].szFooter3, PRT_TF_OTHER_F3);
	inSetFooterText(obTranMap[23].szFooter4, PRT_TF_OTHER_F4);
	inSetFooterText(obTranMap[23].szFooter1B, PRT_TF_OTHER_F1B);
	inSetFooterText(obTranMap[23].szFooter2B, PRT_TF_OTHER_F2B);
	inSetFooterText(obTranMap[23].szFooter3B, PRT_TF_OTHER_F3B);
	inSetFooterText(obTranMap[23].szFooter4B, PRT_TF_OTHER_F4B);

	inSetFooterText(obTranMap[24].szFooter1, PRT_TF_ONLINE_F1);
	inSetFooterText(obTranMap[24].szFooter2, PRT_TF_ONLINE_F2);
	inSetFooterText(obTranMap[24].szFooter3, PRT_TF_ONLINE_F3);
	inSetFooterText(obTranMap[24].szFooter4, PRT_TF_ONLINE_F4);
	inSetFooterText(obTranMap[24].szFooter1B, PRT_TF_ONLINE_F1B);
	inSetFooterText(obTranMap[24].szFooter2B, PRT_TF_ONLINE_F2B);
	inSetFooterText(obTranMap[24].szFooter3B, PRT_TF_ONLINE_F3B);
	inSetFooterText(obTranMap[24].szFooter4B, PRT_TF_ONLINE_F4B);

	inSetFooterText(obTranMap[25].szFooter1, PRT_BAYAR_TIKET_F1);
	inSetFooterText(obTranMap[25].szFooter2, PRT_BAYAR_TIKET_F2);
	inSetFooterText(obTranMap[25].szFooter3, PRT_BAYAR_TIKET_F3);
	inSetFooterText(obTranMap[25].szFooter4, PRT_BAYAR_TIKET_F4);
	inSetFooterText(obTranMap[25].szFooter1B, PRT_BAYAR_TIKET_F1B);
	inSetFooterText(obTranMap[25].szFooter2B, PRT_BAYAR_TIKET_F2B);
	inSetFooterText(obTranMap[25].szFooter3B, PRT_BAYAR_TIKET_F3B);
	inSetFooterText(obTranMap[25].szFooter4B, PRT_BAYAR_TIKET_F4B);

	return 1;
}

int inDoPmtTrxPurchase(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	int inTryCounter = 0;

	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));
	clrscr();

	if (RetVal>0) RetVal = inShowTitle(pobTran);
	if (RetVal>0) RetVal = inGetCard(pobTran);
	if (RetVal>0) RetVal = inBeginComm();
	if (RetVal>0) vdDisplayMerchantName();
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetAmount(pobTran, "AMT RP.");
	if (RetVal>0) RetVal = inSelectAccount(pobTran);
	do {
		if (RetVal>0) RetVal = inShowPobTran(pobTran);
		if (RetVal>0) vdDisplayFee(pobTran);
		//if (RetVal>0) vdScrollDisplay();
		if (RetVal>0) vdDisplayMerchantName();
		if (RetVal>0) vdScrollDisplay();
		memset(pobTran->szRespCode, 0x00, sizeof(pobTran->szRespCode));
		memset(pobTran->szPIN, 0x00, sizeof(pobTran->szPIN));
		inTryCounter++;
		if (inTryCounter==1) {
			if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "ENTER PIN");
			if (RetVal>0) RetVal = inShowPobTran(pobTran);
			if (RetVal>0) vdDisplayFee(pobTran);
			//if (RetVal>0) vdDisplayMerchantName();
			//if (RetVal>0) vdScrollDisplay();
			if (RetVal>0) RetVal = inHorizontalMenuChoice("", "LANJUT", "", "", "BATAL");
			if (RetVal != 1) RetVal = -1;
		} else if (inTryCounter<=3){
			if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "RE-ENTER PIN");
		} else {
			break;
		}
		if (RetVal>0) DisplayStatus("  -----------------  ");
		if (RetVal>0) vdDisplayMerchantName();
		if (RetVal>0) vdScrollDisplay();
		if (RetVal>0) DisplayStatus("Processing...");
		if (inTryCounter==1 && RetVal>0) RetVal = SaveNewBatchRecord(pobTran);
		if (RetVal>0) RetVal = SetBitmap(pobTran);
		if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
		if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 1);  //1 ==> with reversal
		if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
		if (RetVal>0) RetVal = SaveBatchRecordAfterTrx(pobTran);
		if (RetVal>0) RetVal = inDisplayHostResponse(pobTran);
		LOG_PRINTFF((0x08, "RetVal = [%d], Resp = [%s]", RetVal, pobTran->szRespCode));
		if (!strcmp(pobTran->szRespCode, "55")) {
			RetVal = 1;
		} else {
			break;
		}
	} while (!strcmp(pobTran->szRespCode, "55"));
	inEndComm();
	if (RetVal>0) RetVal = inDisplayResponse(pobTran, 0);
	if (RetVal>0) RetVal = PrintResponse(pobTran);
	if (RetVal>0) RetVal = inDisplayResponse(pobTran, 5000);
	return RetVal;
}

int	inDoPmtTrxIsiUlang(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	int inTryCounter = 0;

	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));
	clrscr();

	if (RetVal>0) RetVal = inShowTitle(pobTran);
	if (RetVal>0) RetVal = inGetCard(pobTran);
	if (RetVal>0) RetVal = inBeginComm();
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetGeneralInputNumber_1(pobTran, "NO.HP", 4, 18);
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetVoucherAmt(pobTran, "VOUCHER RP.");
	if (RetVal>0) RetVal = inSelectAccount(pobTran);
	do {
		if (RetVal>0) RetVal = inShowPobTran(pobTran);
		if (RetVal>0) vdScrollDisplay();
		memset(pobTran->szRespCode, 0x00, sizeof(pobTran->szRespCode));
		memset(pobTran->szPIN, 0x00, sizeof(pobTran->szPIN));
		inTryCounter++;
		if (inTryCounter==1) {
			if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "ENTER PIN");
		} else if (inTryCounter<=3){
			if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "RE-ENTER PIN");
		} else {
			break;
		}
		if (RetVal>0) DisplayStatus("  -----------------  ");
		if (RetVal>0) vdScrollDisplay();
		if (RetVal>0) DisplayStatus("Processing...");
		if (inTryCounter==1 && RetVal>0) RetVal = SaveNewBatchRecord(pobTran);
		if (RetVal>0) RetVal = SetBitmap(pobTran);
		if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
		if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 1);  //1 ==> with reversal
		if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
		if (RetVal>0) RetVal = SaveBatchRecordAfterTrx(pobTran);
		if (RetVal>0) RetVal = inDisplayHostResponse(pobTran);
		if (!strcmp(pobTran->szRespCode, "55")) {
			RetVal = 1;
			pobTran->Total = 0;
			memset(pobTran->szTotal, 0x00, sizeof(pobTran->szTotal));
			continue;
		} else {
			break;
		}
	} while (!strcmp(pobTran->szRespCode, "55"));
	inEndComm();
	if (RetVal>0) RetVal = inDisplayResponse(pobTran, 0);
	if (RetVal>0) RetVal = PrintResponse(pobTran);
	if (RetVal>0) RetVal = inDisplayResponse(pobTran, 5000);
	return RetVal;
}

int	inDoPmtTrxRegistrasi(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	int inTryCounter = 0;

	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));
	clrscr();

	if (RetVal>0) RetVal = inShowTitle(pobTran);
	if (RetVal>0) RetVal = inGetCard(pobTran);
	if (RetVal>0) RetVal = inBeginComm();
	if (RetVal>0) RetVal = inDisclaimer("Saya menyetujui isi ketentuan persyaratan PermataMobile. Bila belum membuat TIN, harap membuat TIN terlebih dulu.");
	if (RetVal>0) RetVal = inShowPobTran(pobTran);
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetGeneralInputNumber_1(pobTran, "NO.HP", 4, 16);  //max 16 digit
	do {
		if (RetVal>0) RetVal = inShowPobTran(pobTran);
		if (RetVal>0) vdScrollDisplay();
		memset(pobTran->szRespCode, 0x00, sizeof(pobTran->szRespCode));
		memset(pobTran->szPIN, 0x00, sizeof(pobTran->szPIN));
		inTryCounter++;
		if (inTryCounter==1) {
			if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "ENTER PIN");
		} else if (inTryCounter<=3){
			if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "RE-ENTER PIN");
		} else {
			break;
		}
		if (RetVal>0) DisplayStatus("  -----------------  ");
		if (RetVal>0) vdScrollDisplay();
		if (RetVal>0) DisplayStatus("Processing...");
		if (inTryCounter==1 && RetVal>0) RetVal = SaveNewBatchRecord(pobTran);
		if (RetVal>0) RetVal = SetBitmap(pobTran);
		if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
		if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 0);  //1 ==> with reversal
		if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
		if (RetVal>0) RetVal = inDisplayHostResponse(pobTran);
		if (!strcmp(pobTran->szRespCode, "55")) {
			RetVal = 1;
			pobTran->Total = 0;
			memset(pobTran->szTotal, 0x00, sizeof(pobTran->szTotal));
			continue;
		} else {
			break;
		}
	} while (!strcmp(pobTran->szRespCode, "55"));
	inEndComm();
	if (RetVal>0) RetVal = inDisplayResponse(pobTran, 0);
	if (RetVal>0) RetVal = PrintResponse(pobTran);
	if (RetVal>0) RetVal = inDisplayResponse(pobTran, 5000);
	return RetVal;
}

int	inDoPmtTrxTin(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	int inTryCounter = 0;
	
	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));
	clrscr();

	if (RetVal>0) RetVal = inShowTitle(pobTran);
	if (RetVal>0) RetVal = inGetCard(pobTran);
	if (RetVal>0) RetVal = inBeginComm();
	do {
		if (RetVal>0) RetVal = inShowPobTran(pobTran);
		if (RetVal>0) vdScrollDisplay();
		memset(pobTran->szRespCode, 0x00, sizeof(pobTran->szRespCode));
		memset(pobTran->szPIN, 0x00, sizeof(pobTran->szPIN));
		inTryCounter++;
		if (inTryCounter==1) {
			if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "ENTER PIN");
			if (RetVal>0) vdScrollDisplay();
			if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "ENTER TIN");
			if (RetVal>0) vdScrollDisplay();
			if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "RE-ENTER TIN");
		} else if (inTryCounter<=3){
			if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "RE-ENTER PIN");
		} else {
			break;
		}
		if (RetVal>0) DisplayStatus("  -----------------  ");
		if (RetVal>0) vdScrollDisplay();
		if (RetVal>0) DisplayStatus("Processing...");
		if (inTryCounter==1 && RetVal>0) RetVal = SaveNewBatchRecord(pobTran);
		if (RetVal>0) RetVal = SetBitmap(pobTran);
		if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
		if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 0);  //1 ==> with reversal
		if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
		if (RetVal>0) RetVal = inDisplayHostResponse(pobTran);
		if (!strcmp(pobTran->szRespCode, "55")) {
			RetVal = 1;
			pobTran->Total = 0;
			memset(pobTran->szTotal, 0x00, sizeof(pobTran->szTotal));
			continue;
		} else {
			break;
		}
	} while (!strcmp(pobTran->szRespCode, "55"));
	inEndComm();
	if (RetVal>0) RetVal = inDisplayResponse(pobTran, 5000);
	return RetVal;
}

int inDoPmtTrxInfoSaldo(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	int inTryCounter = 0;
	
	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));
	clrscr();

	if (RetVal>0) RetVal = inShowTitle(pobTran);
	if (RetVal>0) RetVal = inGetCard(pobTran);
	if (RetVal>0) RetVal = inBeginComm();
	if (RetVal>0) RetVal = inSelectAccount(pobTran);
	do {
		if (RetVal>0) RetVal = inShowPobTran(pobTran);
		if (RetVal>0) vdScrollDisplay();
		memset(pobTran->szRespCode, 0x00, sizeof(pobTran->szRespCode));
		memset(pobTran->szPIN, 0x00, sizeof(pobTran->szPIN));
		inTryCounter++;
		if (inTryCounter==1) {
			if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "ENTER PIN");
		} else if (inTryCounter<=3){
			if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "RE-ENTER PIN");
		} else {
			break;
		}
		if (RetVal>0) DisplayStatus("  -----------------  ");
		if (RetVal>0) vdScrollDisplay();
		if (RetVal>0) DisplayStatus("Processing...");
		if (inTryCounter==1 && RetVal>0) RetVal = SaveNewBatchRecord(pobTran);
		if (RetVal>0) RetVal = SetBitmap(pobTran);
		if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
		if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 0);  //1 ==> with reversal
		if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
		if (RetVal>0) RetVal = inDisplayHostResponse(pobTran);
		if (!strcmp(pobTran->szRespCode, "55")) {
			RetVal = 1;
			pobTran->Total = 0;
			memset(pobTran->szTotal, 0x00, sizeof(pobTran->szTotal));
			continue;
		} else {
			break;
		}
	} while (!strcmp(pobTran->szRespCode, "55"));
	inEndComm();
	//if (RetVal>0) RetVal = inDisplayResponse(pobTran, 0);
	//if (RetVal>0) RetVal = PrintResponse(pobTran);
	if (RetVal>0) RetVal = inDisplayResponse(pobTran, 30000L);
	return RetVal;
}

int inDoPmtTrxMiniStatement(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	int inTryCounter = 0;
	
	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));
	clrscr();

	if (RetVal>0) RetVal = inShowTitle(pobTran);
	if (RetVal>0) RetVal = inGetCard(pobTran);
	if (RetVal>0) RetVal = inBeginComm();
	if (RetVal>0) RetVal = inSelectAccount(pobTran);
	do {
		if (RetVal>0) RetVal = inShowPobTran(pobTran);
		if (RetVal>0) vdScrollDisplay();
		memset(pobTran->szRespCode, 0x00, sizeof(pobTran->szRespCode));
		memset(pobTran->szPIN, 0x00, sizeof(pobTran->szPIN));
		inTryCounter++;
		if (inTryCounter==1) {
			if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "ENTER PIN");
		} else if (inTryCounter<=3){
			if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "RE-ENTER PIN");
		} else {
			break;
		}
		if (RetVal>0) DisplayStatus("  -----------------  ");
		if (RetVal>0) vdScrollDisplay();
		if (RetVal>0) DisplayStatus("Processing...");
		if (inTryCounter==1 && RetVal>0) RetVal = SaveNewBatchRecord(pobTran);
		if (RetVal>0) RetVal = SetBitmap(pobTran);
		if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
		if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 0);  //1 ==> with reversal
		if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
		if (RetVal>0) RetVal = inDisplayHostResponse(pobTran);
		if (!strcmp(pobTran->szRespCode, "55")) {
			RetVal = 1;
			pobTran->Total = 0;
			memset(pobTran->szTotal, 0x00, sizeof(pobTran->szTotal));
			continue;
		} else {
			break;
		}
	} while (!strcmp(pobTran->szRespCode, "55"));
	inEndComm();
	if (RetVal>0) RetVal = inDisplayResponse(pobTran, 0);
	if (RetVal>0) RetVal = PrintResponse(pobTran);
	if (RetVal>0) RetVal = inDisplayResponse(pobTran, 5000);
	return RetVal;
}

int inDoPmtTrxInfoCdtCard(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	
	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));
	clrscr();

	if (RetVal>0) RetVal = inShowTitle(pobTran);
	if (RetVal>0) RetVal = inGetCard(pobTran);
	if (RetVal>0) RetVal = inBeginComm();
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetGeneralInputNumber_1(pobTran, "NO.KARTU KREDIT-", 12, 18);
	if (RetVal>0) DisplayStatus("TGL. LAHIR");
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetGeneralInputNumber_2(pobTran, "[DDMMYYYY]", 8, 8);
	if (RetVal>0) DisplayStatus("  -----------------  ");
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) DisplayStatus("Processing...");
	if (RetVal>0) RetVal = SaveNewBatchRecord(pobTran);
	if (RetVal>0) RetVal = SetBitmap(pobTran);
	if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
	if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 0);  //1 ==> with reversal
	if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
	if (RetVal>0) RetVal = inDisplayHostResponse(pobTran);
	inEndComm();
	//if (RetVal>0) RetVal = inDisplayResponse(pobTran, 0);
	//if (RetVal>0) RetVal = PrintResponse(pobTran);
	if (RetVal>0) RetVal = inDisplayResponse(pobTran, 30000L);
	return RetVal;
}

int inDoPmtTrxBillPayment(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	int inTryCounter = 0;
	int inEnterPinFlag=0;
	
	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));
	clrscr();
	
	if (RetVal>0) RetVal = inShowTitle(pobTran);

	pobTran->inCode = PMT_TRX_INFO_BILLING;

	if (RetVal>0) RetVal = inGetCard(pobTran);
	if (RetVal>0) RetVal = inBeginComm();
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) {
		switch (pobTran->inOriginalCode) {
			case PMT_TRX_BAYAR_TELPON:
				RetVal = inGetGeneralInputNumber_1(pobTran, "TELP/HP", 4, 18);
				break;
			case PMT_TRX_BAYAR_PLN :
				RetVal = inGetGeneralInputNumber_1(pobTran, "NO.PLN", 4, 18);
				break;
			case PMT_TRX_BAYAR_PALYJA:
				RetVal = inGetGeneralInputNumber_1(pobTran, "NO.PALYJA", 4, 18);
				break;
			case PMT_TRX_BAYAR_PAM:
				RetVal = inGetGeneralInputNumber_1(pobTran, "NO.PAM", 4, 18);
				break;
			case PMT_TRX_CICILAN_ACC:
				RetVal = inGetGeneralInputNumber_1(pobTran, "NO.KONTRAK-", 4, 18);
				break;
			case PMT_TRX_CICILAN_FIF:
				RetVal = inGetGeneralInputNumber_1(pobTran, "NO.KONTRAK-", 4, 18);
				break;
			case PMT_TRX_CICILAN_TAF:
				RetVal = inGetGeneralInputNumber_1(pobTran, "NO.KONTRAK-", 4, 18);
				break;
			case PMT_TRX_CICILAN_SCB:
				RetVal = inGetGeneralInputNumber_1(pobTran, "NO.KONTRAK-", 4, 18);
				break;
			case PMT_TRX_CICILAN_CITI:
				RetVal = inGetGeneralInputNumber_1(pobTran, "NO.KONTRAK-", 4, 18);
				break;
			case PMT_TRX_CICILAN_ADIRA:
				RetVal = inGetGeneralInputNumber_1(pobTran, "NO.KONTRAK-", 4, 18);
				break;
			case PMT_TRX_BAYAR_PENDIDIKAN:
				if (atoi(pobTran->szAdditionalInfo)==0) {
					RetVal = inGetGeneralInputNumber_1(pobTran, "KD.INST+NO.ID-", 4, 21);
				} else {
					char szMenuName[30];
					memset(szMenuName, 0x00, sizeof(szMenuName));
					inGetMenuName(szMenuName, pobTran->inMenuIndex);
					display_at(1, 7, "INST", CLR_EOL);
					display_at(22-strlen(szMenuName), 7, szMenuName, CLR_EOL);
					vdScrollDisplay();
					RetVal = inGetGeneralInputNumber_1(pobTran, "NO.IDENTITAS-", 4, 18);
				}
				break;
			case PMT_TRX_BAYAR_ASURANSI:
				RetVal = inGetGeneralInputNumber_1(pobTran, "KD.INST+NO.POLIS-", 4, 21);
				break;
			case PMT_TRX_BAYAR_TIKET:
				if (atoi(pobTran->szAdditionalInfo)==0) {
					RetVal = inGetGeneralInputNumber_1(pobTran, "KD.INST+KD.BAYAR-", 4, 21);
				} else {
					char szMenuName[30];
					memset(szMenuName, 0x00, sizeof(szMenuName));
					inGetMenuName(szMenuName, pobTran->inMenuIndex);
					display_at(1, 7, "INST", CLR_EOL);
					display_at(22-strlen(szMenuName), 7, szMenuName, CLR_EOL);
					vdScrollDisplay();
					RetVal = inGetGeneralInputNumber_1(pobTran, "KD.BAYAR-", 4, 18);
				}
				break;
			case PMT_TRX_BAYAR_PAYID:
				RetVal = inGetGeneralInputNumber_1(pobTran, "KD.INST+NO.CUST-", 4, 21);
				break;
			default:
				RetVal = inGetGeneralInputNumber_1(pobTran, "BILL NO.", 4, 18);
				break;
		}
	}
	if (RetVal>0) RetVal = inSelectAccount(pobTran);
	if (RetVal>0) RetVal = inShowPobTran(pobTran);
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "ENTER PIN");
	if (RetVal>0) DisplayStatus("  -----------------  ");
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) DisplayStatus("Processing...");
	
	if (RetVal>0) RetVal = SaveNewBatchRecord(pobTran);
	if (RetVal>0) RetVal = SetBitmap(pobTran);
	if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
	if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 0);  //1 ==> with reversal
	if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
	if (RetVal>0) RetVal = inDisplayHostResponse(pobTran);
	inDisplayResponseMode = 1;
	if (RetVal>0) RetVal = inDisplayResponse(pobTran, 0);
	inDisplayResponseMode = 0;
	//if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) {
		char szJmlTag[2];
		szJmlTag[0] = pobTran->szF48[48+F48_ADD_SIZE];
		szJmlTag[1] = 0x00;
		if (atoi(szJmlTag) <= 0) {
			RetVal = -1;
			DisplayStatus("TIDAK ADA TAGIHAN");
			pause(500);
		}
	}
	if (RetVal>0) {
		if ((pobTran->inOriginalCode==PMT_TRX_CICILAN_ACC) ||
			(pobTran->inOriginalCode==PMT_TRX_CICILAN_FIF) || 
			//(pobTran->inOriginalCode==PMT_TRX_CICILAN_TAF) || 
			(pobTran->inOriginalCode==PMT_TRX_CICILAN_SCB) || 
			(pobTran->inOriginalCode==PMT_TRX_CICILAN_CITI) || 
			(pobTran->inOriginalCode==PMT_TRX_CICILAN_ADIRA) || 
			((pobTran->inOriginalCode==PMT_TRX_BAYAR_PENDIDIKAN) && (strncmp(pobTran->szInputNumber_1, "050", 3)!=0)) || 
			(pobTran->inOriginalCode==PMT_TRX_BAYAR_PAYID)) {
			DisplayStatus("");
			if (RetVal>0) RetVal = inGetAmountForBillPayment(pobTran, "AMT");
			//if (RetVal>0) vdScrollDisplay();
		}
	}
	if (RetVal>0) RetVal = inHorizontalMenuChoice("", "LANJUT", "", "", "BATAL");
	if (RetVal != 1) RetVal = -1;
	if (RetVal>0) {
		pobTran->Status = 0;
		pobTran->inCode = pobTran->inOriginalCode;
	}
	if (RetVal>0) RetVal = SaveBatchRecord(pobTran);

	do {
		if (RetVal>0) RetVal = inDisplayResponse(pobTran, 0);
		memset(SentBuff, 0x00, sizeof(SentBuff));
		memset(RecvBuff, 0x00, sizeof(RecvBuff));
		memset(pobTran->szRespCode, 0x00, sizeof(pobTran->szRespCode));
		inTryCounter++;
		if (inTryCounter<=3 && inEnterPinFlag==1){
			if (RetVal>0) vdScrollDisplay();
			if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "RE-ENTER PIN");
		} else if (inTryCounter>3){
			break;
		}
		if (RetVal>0) DisplayStatus("  -----------------  ");
		if (RetVal>0) vdScrollDisplay();
		if (RetVal>0) DisplayStatus("Processing...");

		if (RetVal>0) RetVal = SetBitmap(pobTran);
		if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
		if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 1);  //1 ==> with reversal
		if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
		if (RetVal>0) RetVal = SaveBatchRecordAfterTrx(pobTran);
		if (RetVal>0) RetVal = inDisplayHostResponse(pobTran);
		LOG_PRINTFF((0x08, "RetVal = [%d], Resp = [%s]", RetVal, pobTran->szRespCode));
		if (!strcmp(pobTran->szRespCode, "55")) {
			memset(pobTran->szPIN, 0x00, sizeof(pobTran->szPIN));
			inEnterPinFlag=1;
			RetVal = 1;
			continue;
		} else {
			break;
		}
	}while (!strcmp(pobTran->szRespCode, "55"));
	inEndComm();
	if (RetVal>0) RetVal = inDisplayResponse(pobTran, 0);
	if (RetVal>0) RetVal = PrintResponse(pobTran);
	if (RetVal>0) RetVal = inDisplayResponse(pobTran, 5000L);
	return RetVal;
}

int inDoPmtTrxBayarTelpon(TRANSACTION_OBJECT *pobTran)
{
	return inDoPmtTrxBillPayment(pobTran);
}

int inDoPmtTrxBayarPln(TRANSACTION_OBJECT *pobTran)
{
	return inDoPmtTrxBillPayment(pobTran);
}

int inDoPmtTrxBayarPalyja(TRANSACTION_OBJECT *pobTran)
{
	return inDoPmtTrxBillPayment(pobTran);
}

int inDoPmtTrxBayarPam(TRANSACTION_OBJECT *pobTran)
{
	return inDoPmtTrxBillPayment(pobTran);
}

int inDoPmtTrxBayarCdtCard(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	int inTryCounter = 0;

	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));
	clrscr();

	if (RetVal>0) RetVal = inShowTitle(pobTran);
	if (RetVal>0) RetVal = inGetCard(pobTran);
	if (RetVal>0) RetVal = inBeginComm();
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) {
		switch (pobTran->inOriginalCode) {
			case PMT_TRX_CICILAN_SCB:
				RetVal = inGetGeneralInputNumber_1(pobTran, "KD.PREFIX+NO.KONTRAK-", 4, 18);
				break;
			case PMT_TRX_CICILAN_CITI:
				RetVal = inGetGeneralInputNumber_1(pobTran, "NO.KONTRAK-", 4, 18);
				break;
			case PMT_TRX_BAYAR_CDTCARD:
				RetVal = inGetGeneralInputNumber_1(pobTran, "NO.KARTU KREDIT-", 12, 18);
				break;
			default:
				RetVal = inGetGeneralInputNumber_1(pobTran, "BILL NO.", 4, 18);
				break;
		}
	}
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetAmount(pobTran, "AMT RP.");
	if (RetVal>0) RetVal = inSelectAccount(pobTran);
	do {
		if (RetVal>0) RetVal = inShowPobTran(pobTran);
		if (RetVal>0) vdScrollDisplay();
		memset(pobTran->szRespCode, 0x00, sizeof(pobTran->szRespCode));
		memset(pobTran->szPIN, 0x00, sizeof(pobTran->szPIN));
		inTryCounter++;
		if (inTryCounter==1) {
			if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "ENTER PIN");
		} else if (inTryCounter<=3){
			if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "RE-ENTER PIN");
		} else {
			break;
		}
		if (RetVal>0) DisplayStatus("  -----------------  ");
		if (RetVal>0) vdScrollDisplay();
		if (RetVal>0) DisplayStatus("Processing...");
		if (inTryCounter==1 && RetVal>0) RetVal = SaveNewBatchRecord(pobTran);
		if (RetVal>0) RetVal = SetBitmap(pobTran);
		if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
		if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 1);  //1 ==> with reversal
		if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
		if (RetVal>0) RetVal = SaveBatchRecordAfterTrx(pobTran);
		if (RetVal>0) RetVal = inDisplayHostResponse(pobTran);
		if (!strcmp(pobTran->szRespCode, "55")) {
			RetVal = 1;
			pobTran->Total = 0;
			memset(pobTran->szTotal, 0x00, sizeof(pobTran->szTotal));
			continue;
		} else {
			break;
		}
	} while (!strcmp(pobTran->szRespCode, "55"));
	inEndComm();
	if (RetVal>0) RetVal = inDisplayResponse(pobTran, 0);
	if (RetVal>0) RetVal = PrintResponse(pobTran);
	if (RetVal>0) RetVal = inDisplayResponse(pobTran, 5000);
	return RetVal;
}

int inDoPmtTrxCicilanAcc(TRANSACTION_OBJECT *pobTran)
{
	return inDoPmtTrxBillPayment(pobTran);
}

int inDoPmtTrxCicilanFif(TRANSACTION_OBJECT *pobTran)
{
	return inDoPmtTrxBillPayment(pobTran);
}

int inDoPmtTrxCicilanTaf(TRANSACTION_OBJECT *pobTran)
{
	return inDoPmtTrxBillPayment(pobTran);
}

int inDoPmtTrxCicilanScb(TRANSACTION_OBJECT *pobTran)
{
	return inDoPmtTrxBayarCdtCard(pobTran);
}

int inDoPmtTrxCicilanCiti(TRANSACTION_OBJECT *pobTran)
{
	return inDoPmtTrxBayarCdtCard(pobTran);
}

int inDoPmtTrxCicilanAdira(TRANSACTION_OBJECT *pobTran)
{
	return inDoPmtTrxBillPayment(pobTran);
}


int inDoPmtTrxBayarPendidikan(TRANSACTION_OBJECT *pobTran)
{
	return inDoPmtTrxBillPayment(pobTran);
}

int inDoPmtTrxBayarAsuransi(TRANSACTION_OBJECT *pobTran)
{
	return inDoPmtTrxBillPayment(pobTran);
}

int inDoPmtTrxBayarTiket(TRANSACTION_OBJECT *pobTran)
{
	return inDoPmtTrxBillPayment(pobTran);
}

int inDoPmtTrxBayarPayid(TRANSACTION_OBJECT *pobTran)
{
	return inDoPmtTrxBillPayment(pobTran);
}

int inDoPmtTrxGeneralTransfer(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	int inTryCounter = 0;
	int inEnterPinFlag = 0;
	
	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));
	clrscr();
	
	if (RetVal>0) RetVal = inShowTitle(pobTran);

	pobTran->inCode = PMT_TRX_INFO_NAME;

	if (RetVal>0) RetVal = inGetCard(pobTran);
	if (RetVal>0) RetVal = inBeginComm();
	if (RetVal>0) {
		if (pobTran->inOriginalCode == PMT_TRX_TRANSFER_BANK_LAIN) {
			if (atoi(pobTran->szAdditionalInfo)==0) {
				if (RetVal>0) vdScrollDisplay();
				if (RetVal>0) RetVal = inGetGeneralInputNumber_2(pobTran, "KD.BANK+NO.REK-", 4, 18);
			} else {
				char szMenuName[30];
				memset(szMenuName, 0x00, sizeof(szMenuName));
				inGetMenuName(szMenuName, pobTran->inMenuIndex);
				if (RetVal>0) vdScrollDisplay();
				if (RetVal>0) display_at(1, 7, "BANK", CLR_EOL);
				if (RetVal>0) display_at(22-strlen(szMenuName), 7, szMenuName, CLR_EOL);
				if (RetVal>0) vdScrollDisplay();
				if (RetVal>0) RetVal = inGetGeneralInputNumber_2(pobTran, "NO.REK", 4, 18);
			}
		} else {
			if (RetVal>0) vdScrollDisplay();
			if (RetVal>0) RetVal = inGetGeneralInputNumber_2(pobTran, "NO.REK", 4, 18);
		}
	} 
	if (RetVal>0) vdScrollDisplay();
	//if (RetVal>0) RetVal = inGetGeneralInputNumber_3(pobTran, "NO.REF", 0, 18);
	//if (RetVal>0) RetVal = InputString("NO.REF ", pobTran->szInputNumber_3);
	if (RetVal>0) RetVal = inNewInputString("NO.REF ", pobTran->szInputNumber_3, 0,18);
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetAmount(pobTran, "AMT RP.");
	if (RetVal>0) RetVal = inSelectAccount(pobTran);
	if (RetVal>0) RetVal = inShowPobTran(pobTran); 
	if (RetVal>0) vdDisplayFee2(pobTran);
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "ENTER PIN");
	if (RetVal>0) DisplayStatus("  -----------------  ");
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) DisplayStatus("Processing...");
	if (RetVal>0) RetVal = SaveNewBatchRecord(pobTran);
	if (RetVal>0) RetVal = SetBitmap(pobTran);
	if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
	if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 0);  //1 ==> with reversal
	if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
	if (RetVal>0) RetVal = inDisplayHostResponse(pobTran);
	if (RetVal>0) RetVal = inDisplayResponse(pobTran, 0);
	if (RetVal>0) RetVal = inHorizontalMenuChoice("", "LANJUT", "", "", "BATAL");
	if (RetVal != 1) RetVal = -1;
	if (RetVal>0) {
		pobTran->Status = 0;
		pobTran->inCode = pobTran->inOriginalCode;
	}
	if (RetVal>0) RetVal = SaveBatchRecord(pobTran);
		
	do {
		if (RetVal>0) RetVal = inDisplayResponse(pobTran, 0);
		memset(SentBuff, 0x00, sizeof(SentBuff));
		memset(RecvBuff, 0x00, sizeof(RecvBuff));
		memset(pobTran->szRespCode, 0x00, sizeof(pobTran->szRespCode));
		inTryCounter++;
		if (inTryCounter<=3 && inEnterPinFlag==1){
			if (RetVal>0) vdScrollDisplay();
			if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "RE-ENTER PIN");
		} else if (inTryCounter>3){
			break;
		}
		if (RetVal>0) DisplayStatus("  -----------------  ");
		if (RetVal>0) vdScrollDisplay();
		if (RetVal>0) DisplayStatus("Processing...");

		if (RetVal>0) RetVal = SetBitmap(pobTran);
		if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
		if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 1);  //1 ==> with reversal
		if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
		if (RetVal>0) RetVal = SaveBatchRecordAfterTrx(pobTran);
		if (RetVal>0) RetVal = inDisplayHostResponse(pobTran);
		if (!strcmp(pobTran->szRespCode, "55")) {
			memset(pobTran->szPIN, 0x00, sizeof(pobTran->szPIN));
			inEnterPinFlag=1;
			RetVal = 1;
			continue;
		} else {
			break;
		}
	}while (!strcmp(pobTran->szRespCode, "55"));
	inEndComm();
	if (RetVal>0) RetVal = inDisplayResponse(pobTran, 0);
	if (RetVal>0) RetVal = PrintResponse(pobTran);
	if (RetVal>0) RetVal = inDisplayResponse(pobTran, 5000L);
	return RetVal;
}

int inDoPmtTrxTransfer(TRANSACTION_OBJECT *pobTran)
{
	return inDoPmtTrxGeneralTransfer(pobTran);
}

int inDoPmtTrxTransferRekLain(TRANSACTION_OBJECT *pobTran)
{
	return inDoPmtTrxGeneralTransfer(pobTran);
}

int inDoPmtTrxTransferBankLain(TRANSACTION_OBJECT *pobTran)
{
	return inDoPmtTrxGeneralTransfer(pobTran);
}

int inDoPmtTrxPinChange(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	int inTryCounter = 0;
	
	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));
	clrscr();

	if (RetVal>0) RetVal = inShowTitle(pobTran);
	if (RetVal>0) RetVal = inGetCard(pobTran);
	if (RetVal>0) RetVal = inBeginComm();
	do {
		if (RetVal>0) RetVal = inShowPobTran(pobTran);
		if (RetVal>0) vdScrollDisplay();
		memset(pobTran->szRespCode, 0x00, sizeof(pobTran->szRespCode));
		memset(pobTran->szPIN, 0x00, sizeof(pobTran->szPIN));
		inTryCounter++;
		if (inTryCounter==1) {
			if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "ENTER PIN");
			if (RetVal>0) vdScrollDisplay();
			if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "ENTER NEW PIN");
			if (RetVal>0) vdScrollDisplay();
			if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "RE-ENTER NEW PIN");
		} else if (inTryCounter<=3){
			if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "RE-ENTER PIN");
		} else {
			break;
		}
		if (RetVal>0) DisplayStatus("  -----------------  ");
		if (RetVal>0) vdScrollDisplay();
		if (RetVal>0) DisplayStatus("Processing...");
		if (inTryCounter==1 && RetVal>0) RetVal = SaveNewBatchRecord(pobTran);
		if (RetVal>0) RetVal = SetBitmap(pobTran);
		if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
		if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 0);  //1 ==> with reversal
		if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
		if (RetVal>0) RetVal = inDisplayHostResponse(pobTran);
		if (!strcmp(pobTran->szRespCode, "55")) {
			RetVal = 1;
			pobTran->Total = 0;
			memset(pobTran->szTotal, 0x00, sizeof(pobTran->szTotal));
			continue;
		} else {
			break;
		}
	} while (!strcmp(pobTran->szRespCode, "55"));
	inEndComm();
	if (RetVal>0) RetVal = inDisplayResponse(pobTran, 5000);
	return RetVal;
}

int inDoPmtTrxBelanjaPoin(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	int inTryCounter = 0;
	
	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));
	clrscr();

	if (RetVal>0) RetVal = inShowTitle(pobTran);
	SVC_WAIT(2000);
	return RetVal;
}




































int inDoInfoPoint(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));
	clrscr();
	if (RetVal>0) RetVal = inShowTitle(pobTran);
	if (RetVal>0) RetVal = inGetCard(pobTran);
	if (RetVal>0) RetVal = inBeginComm();
	if (RetVal>0) DisplayStatus("Processing...");
	if (RetVal>0) RetVal = SetBitmap(pobTran);
	if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
	if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 0); //0 ==> no reversal
	if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
	inEndComm();
	if (RetVal>0) RetVal = PrintResponse(pobTran);
	return RetVal;
}

int inDoCreditPoint(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	
	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));

	clrscr();
	if (RetVal>0) RetVal = inShowTitle(pobTran);
	if (RetVal>0) RetVal = inGetCard(pobTran);
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inBeginComm();
	if (RetVal>0) RetVal = inGetAmount(pobTran, "Amt RP");
	if (RetVal>0) DisplayStatus("Processing...");
	if (RetVal>0) RetVal = SaveNewBatchRecord(pobTran);
	if (RetVal>0) RetVal = SetBitmap(pobTran);
	if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
	if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 1);  //1 ==> with reversal
	if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
	if (RetVal>0) RetVal = SaveBatchRecordAfterTrx(pobTran);

	inEndComm();
	if (RetVal>0) RetVal = PrintResponse(pobTran);
	return RetVal;
}

int inDoCreditPointOffline(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));
	clrscr();
	if (RetVal>0) RetVal = inShowTitle(pobTran);
	if (RetVal>0) RetVal = inGetCard(pobTran);
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetAmount(pobTran, "Amt RP");
	if (RetVal>0) DisplayStatus("Processing...");
	if (RetVal>0) RetVal = SaveNewBatchRecord(pobTran);
	//if (RetVal>0) RetVal = SetBitmap(pobTran);
	//if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
	//if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 1);  //1 ==> with reversal
	//if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
	strcpy(pobTran->szAuthCode, "OFF123");
	strcpy(pobTran->szRespCode, "00");
	//pobTran->Point = 1111;
	pobTran->Status = 1;
	if (RetVal>0) RetVal = SaveBatchRecordAfterTrx(pobTran);
	if (RetVal>0) RetVal = PrintResponse(pobTran);
	return RetVal;
}

int inDoDebetPoint(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	
	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));

	clrscr();
	if (RetVal>0) RetVal = inShowTitle(pobTran);
	if (RetVal>0) RetVal = inGetCard(pobTran);
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inBeginComm();
	if (RetVal>0) RetVal = inGetPoint(pobTran, "Point");
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "PIN");
	if (RetVal>0) DisplayStatus("Processing...");
	if (RetVal>0) RetVal = SaveNewBatchRecord(pobTran);
	if (RetVal>0) RetVal = SetBitmap(pobTran);
	if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
	if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 1);  //1 ==> with reversal
	if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
	if (RetVal>0) RetVal = SaveBatchRecordAfterTrx(pobTran);

	inEndComm();
	if (RetVal>0) RetVal = PrintResponse(pobTran);
	return RetVal;
}

int inDoSendOffline(TRANSACTION_OBJECT *pobTran)
{
	DisplayStatus("Check Offline...");
	FindAndSendOffline();
	SVC_WAIT(500);
	return 1;
}

int inDoInfomasiSaldo(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	
	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));

	clrscr();
	if (RetVal>0) RetVal = inShowTitle(pobTran);

	if (RetVal>0) RetVal = inGetCard(pobTran);
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inBeginComm();

	if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "PIN");
	if (RetVal>0) DisplayStatus("Processing...");
	if (RetVal>0) RetVal = SetBitmap(pobTran);
	if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
	if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 0); //0 ==> no reversal
	if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);

	inEndComm();
	if (RetVal>0) RetVal = PrintResponse(pobTran);

	return RetVal;
}

/*
int inDoTransferDana(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	
	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));

	clrscr();
	if (RetVal>0) RetVal = inShowTitle(pobTran);

	if (RetVal>0) RetVal = inGetCard(pobTran);
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inBeginComm();

	if (RetVal>0) RetVal = inGetRcptAcc(pobTran, "Rcpt");
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetAmount(pobTran, "Amt RP");
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "PIN");
	if (RetVal>0) DisplayStatus("Processing...");
	if (RetVal>0) RetVal = SetBitmap(pobTran);
	if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
	if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 0);  
	if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
	if (RetVal>0) RetVal = GetConfirm(pobTran, "Rek. Tujuan:");
	if (RetVal>0) DisplayStatus("Processing...");

	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));
	pobTran->inCode = TRX_TRANSFER;
	if (RetVal>0) RetVal = inShowTitle(pobTran);
	if (RetVal>0) DisplayStatus("Processing...");
	if (RetVal>0) RetVal = SaveNewBatchRecord(pobTran);
	if (RetVal>0) RetVal = SetBitmap(pobTran);
	if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
	if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 1);  //1 ==> with reversal
	if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
	if (RetVal>0) RetVal = SaveBatchRecordAfterTrx(pobTran);

	inEndComm();
	if (RetVal>0) RetVal = PrintResponse(pobTran);
	return RetVal;
}
*/
/*
int inDoBayarKartuKreditStd(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	
	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));

	clrscr();
	if (RetVal>0) RetVal = inShowTitle(pobTran);
	if (RetVal>0) RetVal = inGetCard(pobTran);
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inBeginComm();
	if (RetVal>0) RetVal = inDisplayRcptName(pobTran, "Issuer");
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetRcptAcc(pobTran, "Card#");
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetAmount(pobTran, "Amt Rp");
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "PIN");
	if (RetVal>0) DisplayStatus("Processing...");
	if (RetVal>0) RetVal = SaveNewBatchRecord(pobTran);
	if (RetVal>0) RetVal = SetBitmap(pobTran);
	if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
	if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 1);  //1 ==> with reversal
	if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
	if (RetVal>0) RetVal = SaveBatchRecordAfterTrx(pobTran);

	inEndComm();
	if (RetVal>0) RetVal = PrintResponse(pobTran);
	return RetVal;
}
*/

/*

int inDoBayarPLN(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	
	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));

	clrscr();
	if (RetVal>0) RetVal = inShowTitle(pobTran);
	if (RetVal>0) RetVal = inGetCard(pobTran);
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inBeginComm();
	if (RetVal>0) RetVal = inGetRcptAcc(pobTran, "Cust.ID");
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "PIN");
	if (RetVal>0) DisplayStatus("Processing...");
	if (RetVal>0) RetVal = SetBitmap(pobTran);
	if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
	if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 0);  
	if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
	if (RetVal>0) RetVal = GetConfirm(pobTran, "Tagihan PLN:");
	if (RetVal>0) DisplayStatus("Processing...");

	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));
	pobTran->inCode = TRX_PAY_PLN;
	if (RetVal>0) RetVal = inShowTitle(pobTran);
	if (RetVal>0) DisplayStatus("Processing...");
	if (RetVal>0) RetVal = SaveNewBatchRecord(pobTran);
	if (RetVal>0) RetVal = SetBitmap(pobTran);
	if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
	if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 1);  //1 ==> with reversal
	if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
	if (RetVal>0) RetVal = SaveBatchRecordAfterTrx(pobTran);

	inEndComm();
	if (RetVal>0) RetVal = PrintResponse(pobTran);
	return RetVal;
}
*/
/*
int inDoBayarTelpon(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	
	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));

	clrscr();
	if (RetVal>0) RetVal = inShowTitle(pobTran);
	if (RetVal>0) RetVal = inGetCard(pobTran);
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inBeginComm();
	if (RetVal>0) RetVal = inDisplayRcptName(pobTran, "Provider");
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetRcptAcc(pobTran, "Phone#");
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "PIN");
	if (RetVal>0) DisplayStatus("Processing...");
	if (RetVal>0) RetVal = SetBitmap(pobTran);
	if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
	if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 0);  
	if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
	if (RetVal>0) RetVal = GetConfirm(pobTran, "Tagihan Telpon:");
	if (RetVal>0) DisplayStatus("Processing...");

	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));
	pobTran->inCode = TRX_PAY_LLPHONE_STD;
	if (RetVal>0) RetVal = inShowTitle(pobTran);
	if (RetVal>0) DisplayStatus("Processing...");
	if (RetVal>0) RetVal = SaveNewBatchRecord(pobTran);
	if (RetVal>0) RetVal = SetBitmap(pobTran);
	if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
	if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 1);  //1 ==> with reversal
	if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
	if (RetVal>0) RetVal = SaveBatchRecordAfterTrx(pobTran);

	inEndComm();
	if (RetVal>0) RetVal = PrintResponse(pobTran);
	return RetVal;
}
*/
/*
int inDoBayarHpStd(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	
	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));

	clrscr();
	if (RetVal>0) RetVal = inShowTitle(pobTran);
	if (RetVal>0) RetVal = inGetCard(pobTran);
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inBeginComm();
	if (RetVal>0) RetVal = inDisplayRcptName(pobTran, "Provider");
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetRcptAcc(pobTran, "Phone#");
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetAmount(pobTran, "Amt Rp");
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "PIN");
	if (RetVal>0) DisplayStatus("Processing...");
	if (RetVal>0) RetVal = SaveNewBatchRecord(pobTran);
	if (RetVal>0) RetVal = SetBitmap(pobTran);
	if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
	if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 1);  //1 ==> with reversal
	if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
	if (RetVal>0) RetVal = SaveBatchRecordAfterTrx(pobTran);

	inEndComm();
	if (RetVal>0) RetVal = PrintResponse(pobTran);
	return RetVal;
}
*/

/*
int inDoTopUpStd(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	
	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));

	clrscr();
	if (RetVal>0) RetVal = inShowTitle(pobTran);
	if (RetVal>0) RetVal = inGetCard(pobTran);
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inBeginComm();
	if (RetVal>0) RetVal = inDisplayRcptName(pobTran, "Kartu");
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = DisplayTotal(pobTran);
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetRcptAcc(pobTran, "Phone#");
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "PIN");
	if (RetVal>0) DisplayStatus("Processing...");
	if (RetVal>0) RetVal = SaveNewBatchRecord(pobTran);
	if (RetVal>0) RetVal = SetBitmap(pobTran);
	if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
	if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 1);  //1 ==> with reversal
	if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
	if (RetVal>0) RetVal = SaveBatchRecordAfterTrx(pobTran);

	inEndComm();
	if (RetVal>0) RetVal = PrintResponse(pobTran);
	return RetVal;
}

*/

/*
int inDoBuyVoucherStd(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	
	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));

	clrscr();
	if (RetVal>0) RetVal = inShowTitle(pobTran);
	if (RetVal>0) RetVal = inGetCard(pobTran);
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inBeginComm();
	if (RetVal>0) RetVal = inDisplayRcptName(pobTran, "Kartu");
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = DisplayTotal(pobTran);
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "PIN");
	if (RetVal>0) DisplayStatus("Processing...");
	if (RetVal>0) RetVal = SaveNewBatchRecord(pobTran);
	if (RetVal>0) RetVal = SetBitmap(pobTran);
	if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
	if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 1);  //1 ==> with reversal
	if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
	if (RetVal>0) RetVal = SaveBatchRecordAfterTrx(pobTran);

	inEndComm();
	if (RetVal>0) RetVal = PrintResponse(pobTran);
	return RetVal;
}

*/

int inDoMiniStatement(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	
	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));
	clrscrplus("* Mini Statement *");
	memset((char *)&obTran, 0x00, sizeof(obTran));
	pobTran->inCode = TRX_MINI_STATEMENT;

	return 1;
}

/*
int inDoRegistrasiMobileBanking(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	
	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));

	clrscr();
	if (RetVal>0) RetVal = inShowTitle(pobTran);
	if (RetVal>0) RetVal = inGetCard(pobTran);
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inBeginComm();
	if (RetVal>0) RetVal = inGetRcptAcc(pobTran, "Phone#");
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "PIN");
	if (RetVal>0) DisplayStatus("Processing...");
	if (RetVal>0) RetVal = SetBitmap(pobTran);
	if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
	if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 0);  //1 ==> with reversal
	if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
	inEndComm();
	if (RetVal>0) RetVal = inDisplayResponse(pobTran, 2000);
	return RetVal;
}
*/

int inDoChangePIN(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	
	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));

	clrscr();
	if (RetVal>0) RetVal = inShowTitle(pobTran);
	if (RetVal>0) RetVal = inGetCard(pobTran);
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inBeginComm();
	if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "PIN");
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "PIN Baru");
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "PIN Baru");
	if (RetVal>0) DisplayStatus("Processing...");
	if (RetVal>0) RetVal = SetBitmap(pobTran);
	if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
	if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 0);  //1 ==> with reversal
	if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
	inEndComm();
	//if (RetVal>0) RetVal = inDisplayResponse(pobTran, "PIN Baru Diterima!");
	return RetVal;
}

int inDoCreateTIN(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	
	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));

	clrscr();
	if (RetVal>0) RetVal = inShowTitle(pobTran);
	if (RetVal>0) RetVal = inGetCard(pobTran);
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inBeginComm();
	if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "PIN");
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "TIN");
	if (RetVal>0) vdScrollDisplay();
	if (RetVal>0) RetVal = inGetEncryptedPin(pobTran, "TIN");
	if (RetVal>0) DisplayStatus("Processing...");
	if (RetVal>0) RetVal = SetBitmap(pobTran);
	if (RetVal>0) RetVal = PackMessage(pobTran, SentBuff);
	if (RetVal>0) RetVal = SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 0);  //1 ==> with reversal
	if (RetVal>0) RetVal = UnpackAndValidateMessage(pobTran, RecvBuff);
	inEndComm();
	//if (RetVal>0) RetVal = inDisplayResponse(pobTran, "TIN Baru Diterima!");
	return RetVal;
}

int inDoReprintLastTrx(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	
	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));

	clrscr();
	if (RetVal>0) RetVal = inShowTitle(pobTran);

	ReprintLastTransaction(pobTran);
	return RetVal;
}

int inDoReprintAnyTrx(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	int RetVal = 1;
	
	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));

	clrscr();
	if (RetVal>0) RetVal = inShowTitle(pobTran);
	
	ReprintAnyTransaction(pobTran);
	return 1;
}

int inDoSummaryReport(TRANSACTION_OBJECT *pobTran)
{
	int RetVal = 1;
	clrscr();
	if (RetVal>0) RetVal = inShowTitle(pobTran);
	//clrscrplus("* Summary Report *");
	if (RetVal>0) PrintSummaryReport("");
	return 1;
}

int inDoDetailReport(TRANSACTION_OBJECT *pobTran)
{
	int RetVal = 1;
	clrscr();
	if (RetVal>0) RetVal = inShowTitle(pobTran);
	//clrscrplus("* Detail Report *");
	if (RetVal>0) PrintDetailReport("");
	return 1;
}

int inDoSummaryPastReport(TRANSACTION_OBJECT *pobTran)
{
	char buff[22];
	long lnNum;

	int RetVal = 1;
	//if (RetVal>0) RetVal = inShowTitle(pobTran);
	clrscrplus("Summary Past Report");

	memset(buff, 0x00, sizeof(buff));
	if (InputNumberEngl("Date (DDMMYY): ", buff, 1L, (long)9999999999L, 0, &lnNum) == 0) return;
	if (strlen(buff) == 6) {
		if ((strncmp(&buff[0], "31", 2)>0) || (strncmp(&buff[2], "12", 2)>0)) {
			DisplayStatus("Invalid Date!");
			vdWarnBeep();
			SVC_WAIT(1000);
			return 0;
		}
	} else {
		DisplayStatus("Invalid Date!");
		vdWarnBeep();
		SVC_WAIT(1000);
		return 0;
	}
	strncpy(&buff[6], &buff[2], 2);
	strncpy(&buff[8], &buff[0], 2);
	strncpy(&buff[0], &buff[4], 6);
	buff[6] = 0x00;
	PrintSummaryReport(buff);
	return 1;
}

int inDoDetailPastReport(TRANSACTION_OBJECT *pobTran)
{
	char buff[22];
	long lnNum;

	int RetVal = 1;
	//if (RetVal>0) RetVal = inShowTitle(pobTran);
	clrscrplus("Detail Past Report");

	memset(buff, 0x00, sizeof(buff));
	if (InputNumberEngl("Date (DDMMYY): ", buff, 1L, (long)9999999999L, 0, &lnNum) == 0) return;
	if (strlen(buff) == 6) {
		if ((strncmp(&buff[0], "31", 2)>0) || (strncmp(&buff[2], "12", 2)>0)) {
			DisplayStatus("Invalid Date!");
			vdWarnBeep();
			SVC_WAIT(1000);
			return 0;
		}
	} else {
		DisplayStatus("Invalid Date!");
		vdWarnBeep();
		SVC_WAIT(1000);
		return 0;
	}
	strncpy(&buff[6], &buff[2], 2);
	strncpy(&buff[8], &buff[0], 2);
	strncpy(&buff[0], &buff[4], 6);
	buff[6] = 0x00;
    PrintDetailReport(buff);
	return 1;
}

int inDoPowerOff(TRANSACTION_OBJECT *pobTran)
{
	int inRetval;
	inRetval = inMenuChoice("TURN OFF?", "RESTART", "TURN OFF", "", "");
	clrscr();
	LOG_PRINTFF((0x08L, "Select = [%d]", inRetval));
	if (inRetval<1 || inRetval>2) return (VS_SUCCESS);

	if ((inRetval==2) && (get_dock_status()==HANDHELD_UNDOCKED)){
		DisplayStatus("RELEASE COMM...");
		inReleaseComm();
		DisplayStatus("RELEASE COMM...[OK]");
		vdScrollDisplay();
		DisplayStatus("SHUTTING DOWN...");
		SVC_SHUTDOWN();
	} else if (inRetval==1){
		DisplayStatus("RELEASE COMM...");
		inReleaseComm();
		DisplayStatus("RELEASE COMM...[OK]");
		vdScrollDisplay();
		DisplayStatus("RESTARTING...");
		SVC_WAIT(2000);
		SVC_RESTART("");
	} else {
		if (inRetval==2){
			DisplayStatus("UNABLE TO TURN OFF");
		}
	}
	SVC_WAIT(2000);
	return VS_SUCCESS;
}

//#define	ASPEN_MODEM_ID		2
//#define	TDK_MODEM_ID		3
//#define	CONNEXANT_MODEM_ID	4
//#define   OMNI_3750_ID	"Q5"
//#define OMNI_3300_ID	"Q7"
//#define OMNI_3350_ID	"Q3"
//#define OMNI_3600_ID	"Q8"
//#define OMNI_3750_ID	"Q5"
//#define OMNI_5150_ID  "QA"

/* Values returned by SVC_INFO_MOD_ID and SVC_INFO_MODULE_ID */
//#define MID_TDK_ONLY            (3)     // TDK 2.4 modem only
//#define MID_CARLOS_ONLY         (5)     // Carlos (Aspen144) modem only
//#define MID_CO561_ONLY          (6)     // Connect One 10BaseT only
//#define MID_CARLOS_CO561        (7)     // Carlos/CO 10baseT combo
//#define MID_CARLOS_MC56         (12)    // Carlos/GSM US combo
//#define MID_CARLOS_MC55         (13)    // Carlos/GSM Int combo
//#define MID_CARLOS_EM3420       (14)    // Carlos/CDMA combo
//#define MID_CARLOS_CO710        (15)    // Carlos/WiFi combo

int inDoChangeComm(TRANSACTION_OBJECT *pobTran)
{
	int inRetVal = 0;
	int inModemType = 0;
	int inPortModem = 0;
	int inModuleID = 0;
	int inSecondModuleID = 0;
	int inCurrComm = 0;
	int shCommLink = 0;
	char buff[128];

	clrscr();
	inShowTitle(pobTran);

	memset(buff, 0x00, sizeof(buff));
	get_env_x(UCL_COMM, 0, buff);
	inCurrComm = atoi(buff);

	memset(buff, 0x00, sizeof(buff));
	SVC_INFO_EPROM(buff);
	inModemType = SVC_INFO_MOD_ID();
	inPortModem = SVC_INFO_PORT_MODEM();
	inModuleID  = SVC_INFO_MODULE_ID (inPortModem);
	inSecondModuleID = SVC_INFO_MODULE_ID(2);
    
	LOG_PRINTFF((0x08L, "Current UCL.COMM = [%d]", inCurrComm));
	LOG_PRINTFF((0x08L, "EPROM = [%s]", buff));
	LOG_PRINTFF((0x08L, "Modem Type = [%d]", inModemType));
	LOG_PRINTFF((0x08L, "Modem Port = [%d]", inPortModem));
	LOG_PRINTFF((0x08L, "Module ID of Port[%d] = [%d]", inPortModem, inModuleID));
	LOG_PRINTFF((0x08L, "Module ID of Port[2] = [%d]", inSecondModuleID));


	if (strstr(buff, "Q5") != (char *) NULL) { //OMNI_3750_ID=="Q5"
		inRetVal = inMenuChoice("Select Comm?", "Dial-Up", "Ethernet", "CDMA", "");
		clrscr();
		LOG_PRINTFF((0x08L, "Select = [%d]", inRetVal));
		if (inRetVal<1 || inRetVal>3) return (VS_SUCCESS);
		if ((inModuleID==3 && inRetVal==2) || 
			(inModuleID==3 && inRetVal==3) ||
			(inModuleID==5 && inRetVal==2) || 
			(inModuleID==5 && inRetVal==3) || 
			(inModuleID==6 && inRetVal==1) || 
			(inModuleID==6 && inRetVal==3) ||
			(inModuleID==7 && inRetVal==3) ||
			(inModuleID==14 && inRetVal==2)){
			DisplayStatus("NOT AVAILABLE!");
			SVC_WAIT(2000);
			return (VS_SUCCESS);
		}
		if (inModuleID!=3 && inModuleID!=5 && inModuleID!=6 && inModuleID!=7 && inModuleID!=14) {
			DisplayStatus("UNSUPPORTED MODEM!");
			SVC_WAIT(2000);
			return (VS_SUCCESS);
		}
		if ((inCurrComm==0 && inRetVal==1) ||
			(inCurrComm==4 && inRetVal==2) ||
			(inCurrComm==7 && inRetVal==3)) {
			DisplayStatus("COMM IN USE!");
			SVC_WAIT(2000);
			return (VS_SUCCESS);
		}
		DisplayStatus("Release comm...");
		inReleaseComm();
		if (inRetVal==1) {
			put_env(UCL_COMM, "8", 1);
		} else if (inRetVal==2) {
			put_env(UCL_COMM, "4", 1);
		} else if (inRetVal==3) {
			put_env(UCL_COMM, "7", 1);
		}
		SVC_WAIT(2000);
		DisplayStatus("Init new comm...");
		memset(buff, 0x00, sizeof(buff));
		if (get_env_x(UCL_COMM, 0, buff)>0) {
			shCommLink = atoi(buff);
			if (inInitializeComm (shCommLink) != VS_SUCCESS ){
				return (0);
			}
		}
		return (1);
	} else if (strstr(buff, "QA") != (char *) NULL) { //#define OMNI_5150_ID  "QA"
		inRetVal = inMenuChoice("Select Comm?", "Dial-Up", "Ethernet", "", "");
		clrscr();
		LOG_PRINTFF((0x08L, "Select = [%d]", inRetVal));
		if (inRetVal<1 || inRetVal>2) return (VS_SUCCESS);
		if (inRetVal != 1) {
			DisplayStatus("NOT AVAILABLE!");
			SVC_WAIT(2000);
			return (VS_SUCCESS);
		}
		if ((inCurrComm==0 && inRetVal==1) ||
			(inCurrComm==4 && inRetVal==2)) {
			DisplayStatus("COMM IN USE!");
			SVC_WAIT(2000);
			return (VS_SUCCESS);
		}
		DisplayStatus("Release comm...");
		inReleaseComm();
		if (inRetVal==1) {
			put_env(UCL_COMM, "8", 1);
		} else if (inRetVal==2) {
			put_env(UCL_COMM, "4", 1);
		} 
		SVC_WAIT(2000);
		DisplayStatus("Init new comm...");
		memset(buff, 0x00, sizeof(buff));
		if (get_env_x(UCL_COMM, 0, buff)>0) {
			shCommLink = atoi(buff);
			if (inInitializeComm (shCommLink) != VS_SUCCESS ){
				return (0);
			}
		}
		return (1);

	} else if (strstr(buff, "QB") != (char *) NULL) { //Vx610 == "QB"
		inRetVal = inMenuChoice("Select Comm?", "Dial", "WiFi", "GPRS", "CDMA");
		clrscr();
		LOG_PRINTFF((0x08L, "Select = [%d]", inRetVal));
		if (inRetVal<1 || inRetVal>4) return (VS_SUCCESS);

		if (inModuleID==4 && inRetVal==1) {
		} else if (inSecondModuleID==255 && inRetVal==4) { //255==CDMA?
		} else if (inSecondModuleID==9   && inRetVal==3) { //9  ==GPRS
		} else {
			DisplayStatus("NOT AVAILABLE!");
			SVC_WAIT(2000);
			return (1);
		}
		if ((inCurrComm==0 && inRetVal==1) ||
			(inCurrComm==5 && inRetVal==2) ||
			(inCurrComm==6 && inRetVal==3) ||
			(inCurrComm==7 && inRetVal==4) ) {
			DisplayStatus("COMM IN USE!");
			SVC_WAIT(2000);
			return (VS_SUCCESS);
		}
		DisplayStatus("Release comm...");
		inReleaseComm();
		if (inRetVal==1) {
			put_env("UCL.COMM", "8", 1);
		} else if (inRetVal==2) {
			put_env("UCL.COMM", "5", 1);
		} else if (inRetVal==3) {
			put_env("UCL.COMM", "6", 1);
		} else if (inRetVal==4) {
			put_env("UCL.COMM", "7", 1);
		} 
		SVC_WAIT(2000);
		DisplayStatus("Init new comm...");
		memset(buff, 0x00, sizeof(buff));
		if (get_env_x(UCL_COMM, 0, buff)>0) {
			shCommLink = atoi(buff);
			if (inInitializeComm (shCommLink) != VS_SUCCESS ){
				return (0);
			}
		}
		return (1);
	} else {
		DisplayStatus("UNSUPPORTED TERMINAL!");
		SVC_WAIT(2000);
		return (VS_SUCCESS);
	}
}

int inDoSendReversal(TRANSACTION_OBJECT *pobTran)
{
	DisplayStatus("Check Reversal...");
	FindAndSendReversal();
	SVC_WAIT(500);
	return 1;
}

int inDoVerifySetup(TRANSACTION_OBJECT *pobTran)
{
	return BeginSetup();
}

int inDoSetupPrimaryPhone(TRANSACTION_OBJECT *pobTran)
{
	int RetVal = 1;
	//if (RetVal>0) RetVal = inShowTitle(pobTran);
	if (RetVal>0) RetVal = DoSetPriAuthPhone();
	return 1;
}

int inDoSetupSecondaryPhone(TRANSACTION_OBJECT *pobTran)
{
	int RetVal = 1;
	//if (RetVal>0) RetVal = inShowTitle(pobTran);
	if (RetVal>0) RetVal = DoSetSecAuthPhone();
	return 1;
}

int inDoSetupInitParameter(TRANSACTION_OBJECT *pobTran)
{
	clrscr();
	inShowTitle(pobTran);
	return inDoSetupPartialDownload(pobTran);
}

int inDoSetupPartialDownload(TRANSACTION_OBJECT *pobTran)
{
    int inResult=1;
	char buff[128];
	char chPvsBuffer[128];
	int  inRes;
	int  i;

	clrscr();
	inShowTitle(pobTran);
/*
    if(( fChkAllHostBatches(pobTran) == VS_FALSE ) || (fOpenTabEmpty(pobTran) == VS_FALSE)) {
        vdDisplayMessageFromFile( BATCH_NOT_EMPTY_ERR_MSG15, ERROR_MSG);
        return ( VS_ERR );
    }
*/
	memset(chPvsBuffer, 0x00, sizeof(chPvsBuffer));
	inRes = SVC_INFO_SERLNO(chPvsBuffer);
	for (i=0; i<strlen(chPvsBuffer); i++) {
		if (!isdigit(chPvsBuffer[i])) {
			strcpy(&chPvsBuffer[i], &chPvsBuffer[i+1]);
			i--;
		}
	}
	if (strlen(chPvsBuffer)>9) {
		strcpy(chPvsBuffer, &chPvsBuffer[strlen(chPvsBuffer)-9]);
	}
	if (strlen(chPvsBuffer)<9) {
		DisplayStatus("Error Get SN");
		SVC_WAIT(2000);
		return (0);
	}
	memset(buff, 0x00, sizeof(buff));
	sprintf(buff, "S/N  : %s", chPvsBuffer); 
	display_at(1, 7, buff, CLR_EOL);
	if (inResult>=0) inResult = put_env("*ZT", chPvsBuffer, strlen(chPvsBuffer));
	
	if (inUseSNasTID()==0) {
		vdScrollDisplay();
		memset(buff, 0x00, sizeof(buff));
		if (inResult>=0) inResult = InputString("TID  : ", buff);
		if (inResult>=0) inResult = put_env("*ZT", buff, strlen(buff));
	}

	vdScrollDisplay();
	memset(buff, 0x00, sizeof(buff));
	if (inResult>=0) inResult = InputString("Phone: ", buff);
	if (buff[0] != 'T') {
		memmove(&buff[1], buff, strlen(buff));
		buff[0] = 'T';
	}
	if (inResult>=0) inResult = put_env("*ZP", buff, strlen(buff));
	vdScrollDisplay();
/*
	memset(buff, 0x00, sizeof(buff));
	if (inResult>=0) inResult = InputString("Appl : ", buff);
	if (inResult>=0) inResult = put_env("*ZA", buff, strlen(buff));
	vdScrollDisplay();
*/
#ifdef __arm
		if (inResult>=0) inResult = put_env("*ZA", "VxCATM40", strlen("VxCATM40"));
		if (inResult>=0) inResult = put_env("*ZINIT", "ATE1M0V0&D2&Q6%E0%C1&K0&J3S0=1", strlen("ATE1M0V0&D2&Q6%E0%C1&K0&J3S0=1"));
		if (inResult>=0) inResult = put_env("*ZRESP", "16", strlen("16"));
		if (inResult>=0) inResult = put_env("*ZRESET", "atz0", strlen("atz0"));
		if (inResult>=0) inResult = put_env("*ZR", "6", strlen("6"));
		if (inResult>=0) inResult = put_env("*ZSWESC", "+++", strlen("+++"));
#else
	//if (SVC_INFO_MODULE_ID(SVC_INFO_PORT_MODEM())==3){
		if (inResult>=0) inResult = put_env("*ZA", "CATM40", strlen("CATM40"));
		if (inResult>=0) inResult = put_env("*ZINIT", "ATE0V0K0S0=1", strlen("ATE0V0K0S0=1"));
		if (inResult>=0) inResult = put_env("*ZRESP", "10", strlen("10"));
		if (inResult>=0) inResult = put_env("*ZRESET", "atz", strlen("atz"));
		if (inResult>=0) inResult = put_env("*ZR", "3", strlen("3"));
		if (inResult>=0) inResult = put_env("*ZSWESC", "+++", strlen("+++"));
	//}
#endif

	if (inResult>=0) DisplayStatus("Wait...");


    if (inResult>=0) inResult = inCallZontalk('P');
    SVC_RESTART("CATM.OUT");

    return(!inResult);
}

int inDoSetupFullDownload(TRANSACTION_OBJECT *pobTran)
{
    int inResult=1;
	char buff[128];
	char chPvsBuffer[128];
	int  inRes;
	int  i;

	clrscr();
	inShowTitle(pobTran);
/*
    if(( fChkAllHostBatches(pobTran) == VS_FALSE ) || (fOpenTabEmpty(pobTran) == VS_FALSE)) {
        vdDisplayMessageFromFile( BATCH_NOT_EMPTY_ERR_MSG15, ERROR_MSG);
        return ( VS_ERR );
    }
*/
	memset(chPvsBuffer, 0x00, sizeof(chPvsBuffer));
	inRes = SVC_INFO_SERLNO(chPvsBuffer);
	for (i=0; i<strlen(chPvsBuffer); i++) {
		if (!isdigit(chPvsBuffer[i])) {
			strcpy(&chPvsBuffer[i], &chPvsBuffer[i+1]);
			i--;
		}
	}
	if (strlen(chPvsBuffer)>9) {
		strcpy(chPvsBuffer, &chPvsBuffer[strlen(chPvsBuffer)-9]);
	}
	if (strlen(chPvsBuffer)<9) {
		DisplayStatus("Error Get SN");
		SVC_WAIT(2000);
		return (0);
	}
	memset(buff, 0x00, sizeof(buff));
	sprintf(buff, "S/N  : %s", chPvsBuffer); 
	display_at(1, 7, buff, CLR_EOL);
	if (inResult>=0) inResult = put_env("*ZT", chPvsBuffer, strlen(chPvsBuffer));
	
	if (inUseSNasTID()==0) {
		vdScrollDisplay();
		memset(buff, 0x00, sizeof(buff));
		if (inResult>=0) inResult = InputString("TID  : ", buff);
		if (inResult>=0) inResult = put_env("*ZT", buff, strlen(buff));
	}

	vdScrollDisplay();
	memset(buff, 0x00, sizeof(buff));
	if (inResult>=0) inResult = InputString("Phone: ", buff);
	if (buff[0] != 'T') {
		memmove(&buff[1], buff, strlen(buff));
		buff[0] = 'T';
	}
	if (inResult>=0) inResult = put_env("*ZP", buff, strlen(buff));
	vdScrollDisplay();

#ifdef __arm
		if (inResult>=0) inResult = put_env("*ZA", "VxCATM40", strlen("VxCATM40"));
		if (inResult>=0) inResult = put_env("*ZINIT", "ATE1M0V0&D2&Q6%E0%C1&K0&J3S0=1", strlen("ATE1M0V0&D2&Q6%E0%C1&K0&J3S0=1"));
		if (inResult>=0) inResult = put_env("*ZRESP", "16", strlen("16"));
		if (inResult>=0) inResult = put_env("*ZRESET", "atz0", strlen("atz0"));
		if (inResult>=0) inResult = put_env("*ZR", "6", strlen("6"));
		if (inResult>=0) inResult = put_env("*ZSWESC", "+++", strlen("+++"));
#else
	//if (SVC_INFO_MODULE_ID(SVC_INFO_PORT_MODEM())==3){
		if (inResult>=0) inResult = put_env("*ZA", "CATM40", strlen("CATM40"));
		if (inResult>=0) inResult = put_env("*ZINIT", "ATE0V0K0S0=1", strlen("ATE0V0K0S0=1"));
		if (inResult>=0) inResult = put_env("*ZRESP", "10", strlen("10"));
		if (inResult>=0) inResult = put_env("*ZRESET", "atz", strlen("atz"));
		if (inResult>=0) inResult = put_env("*ZR", "3", strlen("3"));
		if (inResult>=0) inResult = put_env("*ZSWESC", "+++", strlen("+++"));
	//}
#endif
/*
	memset(buff, 0x00, sizeof(buff));
	if (inResult>=0) inResult = InputString("Appl : ", buff);
	if (inResult>=0) inResult = put_env("*ZA", buff, strlen(buff));
	vdScrollDisplay();
*/	
	if (inResult>=0) DisplayStatus("Wait...");


    if (inResult>=0) inResult = inCallZontalk('F');
    if (inResult < 0) SVC_RESTART("CATM.OUT");  //if started but not success, just restart it
	 //SVC_RESTART("");  //=F2+F4, power reset
    return (1);

		//SVC_ZONTALK('F');  //Full download, restart
		//SVC_ZONTALK('P');  //Full/partial; force a restart of the app
		//SVC_ZONTALK('p');  //partial; resume execution
		//SVC_ZONTALK('R');  //(for GID1 app only); Delete all app files in all group and drive; flash coalesced; Full download 
		//SVC_ZONTALK('r');  //same like 'R' except flash is not coalesced
		
		// *ZT=Terminal ID
		// *ZA=Application ID
		// *ZP=Host telephone #
		// *ZR=Baud Rate (2=1200; 3=2400 (default); 4=4800; 5=9600; 6=19200)
		// *ZINIT=Modem init string ATM0V0&D2
		// *ZRESET=Modem reset string ATZ0
		// *ZRESP=Modem Connect Respon. "CONNECT 2400"
		// *ZSWESC=Modem software escape flag
}

int inDoSetupSetMasterKey(TRANSACTION_OBJECT *pobTran)
{
    int inResult=1;
	char buff[128];
	int i;
	char MKAddr;

	clrscr();
	inShowTitle(pobTran);
	
	do {
		memset(buff, 0x00, sizeof(buff));
		ClearSevenLine();
		if (inResult>=0) inResult = InputString("KEY: ", buff);
		if (inResult<0) return 1;
		for (i=0; i<strlen(buff); i++) {
			if ((buff[i]<'0') || ((buff[i]>'9')&&(buff[i]<'A')) || (buff[i]>'F')){
				DisplayStatus("Invalid Input");
				SVC_WAIT(500);
				memset(buff, 0x00, sizeof(buff));
				break;
			}
		}
	} while (strlen(buff)!=16);
	
	if (strlen(pobTran->szAdditionalInfo)) {
		vdTrimSpace(pobTran->szAdditionalInfo);
		MKAddr = pobTran->szAdditionalInfo[0];
	} else {
		MKAddr = chGetMasterKeyAddress();
	}
	if (inResult>=0) inResult = inTransferMasterKey(MKAddr, buff);
	if (inResult==VS_SUCCESS) {
		DisplayStatus("MasterKey Injected");
	} else {
		DisplayStatus("Fail, Try Again");
		vdWarnBeep();
	}
	SVC_WAIT(2000);
	return 1;
}

int inDoSetupChangeBIN(TRANSACTION_OBJECT *pobTran)
{
	int RetVal = 1;
	//if (RetVal>0) RetVal = inShowTitle(pobTran);
	if (RetVal>0) RetVal = DoChangeBIN();
	return 1;
}

int inDoSetupChangePassword(TRANSACTION_OBJECT *pobTran)
{
	int RetVal = 1;
	//if (RetVal>0) RetVal = inShowTitle(pobTran);
	if (RetVal>0) RetVal = DoChangePassword();
	return 1;
}

int inDoSelectMenu(TRANSACTION_OBJECT *pobTran)
{
	clrscr();
	inShowTitle(pobTran);
	return inMenuSelection();
}

int inDoClearReversal(TRANSACTION_OBJECT *pobTran)
{
	int fhandle;
	int bytes;
	int found = 0;

	clrscrplus("Clear Reversal");
	fhandle = open("BATCH", O_RDWR);
	if (fhandle == -1) return 0;
	do {
		memset((void *)pobTran, 0x00, sizeof(TRANSACTION_OBJECT));
		bytes = read(fhandle, (void *)pobTran, sizeof(TRANSACTION_OBJECT));
		if (bytes == sizeof(TRANSACTION_OBJECT)){
			if (pobTran->Status == 1 || pobTran->Status == 3) {  //reversal found
				found = 1;
				break;
			}
		}else{
			break;
		}
	}while (1);
	if (found) {
		if (pobTran->RecordNo % BATCH_SIZE){
			lseek(fhandle, (long)(((pobTran->RecordNo % BATCH_SIZE)-1)*sizeof(TRANSACTION_OBJECT)), SEEK_SET);
		} else {
			lseek(fhandle, (long)((BATCH_SIZE-1)*sizeof(TRANSACTION_OBJECT)), SEEK_SET);
		}
		pobTran->Status=0;
		write(fhandle, (void *)pobTran, sizeof(TRANSACTION_OBJECT));
	}
	close(fhandle);	
	DisplayStatus("Successfully Cleared");
	SVC_WAIT(1000);
	return 1;
}

int inDoClearBatch(TRANSACTION_OBJECT *pobTranGlobal)
{
	int fhandle;
	long countbyte;
	TRANSACTION_OBJECT pobTran;
	int i;

	clrscrplus("Clear Batch");
	memset((void *)&pobTran, 0x00, sizeof(TRANSACTION_OBJECT));
	fhandle = open("BATCH", O_RDWR);
	if (fhandle != -1) {
		for (i=0; i<BATCH_SIZE; i++) {
			pobTran.RecordNo = 0;
			countbyte = write(fhandle, (const void *)&pobTran, sizeof(TRANSACTION_OBJECT));
			if (countbyte != sizeof(TRANSACTION_OBJECT)) {
				DisplayStatus("Not Enough Memory!");
				while(1);
			}
		}	
	}
	close(fhandle);
	DisplayStatus("Successfully Cleared");
	SVC_WAIT(1000);
	return 1;
}

int inDoExit(TRANSACTION_OBJECT *pobTran)
{
	ExitApp();
	return 1;
}

int inDoUtility(TRANSACTION_OBJECT *pobTran)
{
	char szBuffer[128];

	clrscr();
	inShowTitle(pobTran);
	return 1;
}

int inDoDummy(TRANSACTION_OBJECT *pobTran)
{
	clrscr();
	inShowTitle(pobTran);
	DisplayStatus("SORRY");
	vdScrollDisplay();
	DisplayStatus("UNDER CONSTRUCTION");
	vdScrollDisplay();
	pause(300);
	return 1;
}

//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////

int inShowTitle(TRANSACTION_OBJECT *pobTran)
{
	char msgbuff[22];
	char msg[22];
	int i=0;

	memset(msg, 0x00, sizeof(msg));
	for (i=0; i<obTranMapCount; i++){  //get szCode of TRANSACTION_BITMAP to display
		if (pobTran->inCode == obTranMap[i].inCode) {
			strcpy(msg, obTranMap[i].szCode);
			break;
		}
	}
	if (strlen(msg)==0) {				//get Name of SMENU to display
		inGetMenuName(msg, pobTran->inMenuIndex);
	}
	if (strlen(msg)>21) {
		strncpy(msgbuff, msg, 21);
		msg[21] = 0x00;
	} else if (strlen(msg)){
		strcpy(msgbuff, msg);
	}
	DisplayJudul(msgbuff);
	return 1;
}

int inShowPobTran(TRANSACTION_OBJECT *pobTran)
{
    char buff[40];

	ClearSevenLine();

	if (strlen(pobTran->szPAN)) {
		display_at(1, 7, "PAN", CLR_EOL);
		display_at(22-strlen(pobTran->szPAN), 7, pobTran->szPAN, CLR_EOL);
	}
	if (strlen(pobTran->szExpDate)) {
		vdScrollDisplay();
		memset(buff, 0x00, sizeof(buff));
		strncat(buff, &pobTran->szExpDate[2], 2);
		strncat(buff, &pobTran->szExpDate[0], 2);
		display_at(1, 7, "EXP.(MMYY)", CLR_EOL);
		display_at(22-strlen(buff), 7, buff, CLR_EOL);
	}
/*
	if (strlen(pobTran->szCHolder)>0) {
		vdScrollDisplay();
		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, pobTran->szCHolder, 21);
		display_at(1, 7, "Name", CLR_EOL);
		display_at(22-strlen(buff), 7, buff, CLR_EOL);
	}
*/
	if (pobTran->inCode == PMT_TRX_PURCHASE) {
		if (pobTran->Total>0) {
			char NumBuff[48];
			vdDisplayMerchantName();
			vdScrollDisplay();
			memset(buff, 0x00, sizeof(buff));
			memset(NumBuff, 0x00, sizeof(NumBuff));
			FormatNumInd(NumBuff, pobTran->Total);
			NumBuff[12] = 0x00;
			sprintf(buff, "AMT RP. %13s", NumBuff);
			display_at(1, 7, buff, CLR_EOL);
			//vdDisplayFee(pobTran);
		}
	}

	if (pobTran->inCode == PMT_TRX_ISI_ULANG) {
		if (strlen(pobTran->szInputNumber_1)) {
			vdScrollDisplay();
			display_at(1, 7, "NO.HP", CLR_EOL);
			display_at(22-strlen(pobTran->szInputNumber_1), 7, pobTran->szInputNumber_1, CLR_EOL);
		}
		if (pobTran->lnVoucherAmt>0) {
			char NumBuff[48];
			vdScrollDisplay();
			memset(buff, 0x00, sizeof(buff));
			memset(NumBuff, 0x00, sizeof(NumBuff));
			FormatNumInd(NumBuff, pobTran->lnVoucherAmt);
			NumBuff[13] = 0x00;
			sprintf(buff, "VOUCHER RP.%10s", NumBuff);
			display_at(1, 7, buff, CLR_EOL);
		}
	}

	if (pobTran->inCode == PMT_TRX_REGISTRASI && strlen(pobTran->szInputNumber_1)) {
		vdScrollDisplay();
		display_at(1, 7, "NO.HP", CLR_EOL);
		display_at(22-strlen(pobTran->szInputNumber_1), 7, pobTran->szInputNumber_1, CLR_EOL);
	}
	
	if (pobTran->inCode == PMT_TRX_INFO_CDTCARD) {
		if (strlen(pobTran->szInputNumber_1)) {
			vdScrollDisplay();
			display_at(1, 7, "NO.KARTU KREDIT", CLR_EOL);
			vdScrollDisplay();
			display_at(22-strlen(pobTran->szInputNumber_1), 7, pobTran->szInputNumber_1, CLR_EOL);
		}
		if (strlen(pobTran->szInputNumber_2)) {
			vdScrollDisplay();
			display_at(1, 7, "TGL. LAHIR", CLR_EOL);
			display_at(22-strlen(pobTran->szInputNumber_2), 7, pobTran->szInputNumber_2, CLR_EOL);
		}
	}
	if (pobTran->inOriginalCode == PMT_TRX_BAYAR_TELPON) {
		if (strlen(pobTran->szInputNumber_1)) {
			vdScrollDisplay();
			display_at(1, 7, "TELP/HP", CLR_EOL);
			display_at(22-strlen(pobTran->szInputNumber_1), 7, pobTran->szInputNumber_1, CLR_EOL);
		}
	}
	if (pobTran->inOriginalCode == PMT_TRX_BAYAR_PLN) {
		if (strlen(pobTran->szInputNumber_1)) {
			vdScrollDisplay();
			display_at(1, 7, "NO.PLN", CLR_EOL);
			display_at(22-strlen(pobTran->szInputNumber_1), 7, pobTran->szInputNumber_1, CLR_EOL);
		}
	}
	if (pobTran->inOriginalCode == PMT_TRX_BAYAR_PALYJA) {
		if (strlen(pobTran->szInputNumber_1)) {
			vdScrollDisplay();
			display_at(1, 7, "NO.PALYJA", CLR_EOL);
			display_at(22-strlen(pobTran->szInputNumber_1), 7, pobTran->szInputNumber_1, CLR_EOL);
		}
	}
	if (pobTran->inOriginalCode == PMT_TRX_BAYAR_PAM) {
		if (strlen(pobTran->szInputNumber_1)) {
			vdScrollDisplay();
			display_at(1, 7, "NO.PAM", CLR_EOL);
			display_at(22-strlen(pobTran->szInputNumber_1), 7, pobTran->szInputNumber_1, CLR_EOL);
		}
	}
	if (pobTran->inOriginalCode == PMT_TRX_CICILAN_ACC) {
		if (strlen(pobTran->szInputNumber_1)) {
			vdScrollDisplay();
			display_at(1, 7, "NO.KONTRAK", CLR_EOL);
			vdScrollDisplay();
			display_at(22-strlen(pobTran->szInputNumber_1), 7, pobTran->szInputNumber_1, CLR_EOL);
		}
	}
	if (pobTran->inOriginalCode == PMT_TRX_CICILAN_FIF) {
		if (strlen(pobTran->szInputNumber_1)) {
			vdScrollDisplay();
			display_at(1, 7, "NO.KONTRAK", CLR_EOL);
			vdScrollDisplay();
			display_at(22-strlen(pobTran->szInputNumber_1), 7, pobTran->szInputNumber_1, CLR_EOL);
		}
	}
	if (pobTran->inOriginalCode == PMT_TRX_CICILAN_TAF) {
		if (strlen(pobTran->szInputNumber_1)) {
			vdScrollDisplay();
			display_at(1, 7, "NO.KONTRAK", CLR_EOL);
			vdScrollDisplay();
			display_at(22-strlen(pobTran->szInputNumber_1), 7, pobTran->szInputNumber_1, CLR_EOL);
		}
	}

	if (pobTran->inOriginalCode == PMT_TRX_CICILAN_SCB) {
		if (strlen(pobTran->szInputNumber_1)) {
			vdScrollDisplay();
			display_at(1, 7, "KD.PREFIX+NO.KONTRAK", CLR_EOL);
			vdScrollDisplay();
			display_at(22-strlen(pobTran->szInputNumber_1), 7, pobTran->szInputNumber_1, CLR_EOL);
		}
		if (pobTran->Total>0) {
			char NumBuff[48];
			vdScrollDisplay();
			memset(buff, 0x00, sizeof(buff));
			memset(NumBuff, 0x00, sizeof(NumBuff));
			FormatNumInd(NumBuff, pobTran->Total);
			NumBuff[12] = 0x00;
			sprintf(buff, "AMT RP. %13s", NumBuff);
			display_at(1, 7, buff, CLR_EOL);
		}
	}
	if (pobTran->inOriginalCode == PMT_TRX_CICILAN_CITI) {
		if (strlen(pobTran->szInputNumber_1)) {
			vdScrollDisplay();
			display_at(1, 7, "NO.KONTRAK", CLR_EOL);
			vdScrollDisplay();
			display_at(22-strlen(pobTran->szInputNumber_1), 7, pobTran->szInputNumber_1, CLR_EOL);
		}
		if (pobTran->Total>0) {
			char NumBuff[48];
			vdScrollDisplay();
			memset(buff, 0x00, sizeof(buff));
			memset(NumBuff, 0x00, sizeof(NumBuff));
			FormatNumInd(NumBuff, pobTran->Total);
			NumBuff[12] = 0x00;
			sprintf(buff, "AMT RP. %13s", NumBuff);
			display_at(1, 7, buff, CLR_EOL);
		}
	}
	if (pobTran->inOriginalCode == PMT_TRX_CICILAN_ADIRA) {
		if (strlen(pobTran->szInputNumber_1)) {
			vdScrollDisplay();
			display_at(1, 7, "NO.KONTRAK", CLR_EOL);
			vdScrollDisplay();
			display_at(22-strlen(pobTran->szInputNumber_1), 7, pobTran->szInputNumber_1, CLR_EOL);
		}
	}

	if (pobTran->inOriginalCode == PMT_TRX_BAYAR_PENDIDIKAN) {
		if (strlen(pobTran->szInputNumber_1)) {
			if (atoi(pobTran->szAdditionalInfo)==0) {
				vdScrollDisplay();
				display_at(1, 7, "KD.INST+NO.ID", CLR_EOL);
				vdScrollDisplay();
				display_at(22-strlen(pobTran->szInputNumber_1), 7, pobTran->szInputNumber_1, CLR_EOL);
			} else {
				char szMenuName[30];
				memset(szMenuName, 0x00, sizeof(szMenuName));
				inGetMenuName(szMenuName, pobTran->inMenuIndex);
				vdScrollDisplay();
				display_at(1, 7, "INST", CLR_EOL);
				display_at(22-strlen(szMenuName), 7, szMenuName, CLR_EOL);
				vdScrollDisplay();
				display_at(1, 7, "NO.IDENTITAS", CLR_EOL);
				vdScrollDisplay();
				display_at(22-strlen(pobTran->szInputNumber_1), 7, pobTran->szInputNumber_1, CLR_EOL);
			}			
		}
	}
	if (pobTran->inOriginalCode == PMT_TRX_BAYAR_ASURANSI) {
		if (strlen(pobTran->szInputNumber_1)) {
			vdScrollDisplay();
			display_at(1, 7, "KD.INST+NO.POLIS", CLR_EOL);
			vdScrollDisplay();
			display_at(22-strlen(pobTran->szInputNumber_1), 7, pobTran->szInputNumber_1, CLR_EOL);
		}
	}
	if (pobTran->inOriginalCode == PMT_TRX_BAYAR_TIKET) {
		if (strlen(pobTran->szInputNumber_1)) {
			if (atoi(pobTran->szAdditionalInfo)==0) {
				vdScrollDisplay();
				display_at(1, 7, "KD.INST+KD.BAYAR", CLR_EOL);
				vdScrollDisplay();
				display_at(22-strlen(pobTran->szInputNumber_1), 7, pobTran->szInputNumber_1, CLR_EOL);
			} else {
				char szMenuName[30];
				memset(szMenuName, 0x00, sizeof(szMenuName));
				inGetMenuName(szMenuName, pobTran->inMenuIndex);
				vdScrollDisplay();
				display_at(1, 7, "INST", CLR_EOL);
				display_at(22-strlen(szMenuName), 7, szMenuName, CLR_EOL);
				vdScrollDisplay();
				display_at(1, 7, "KD.BAYAR", CLR_EOL);
				vdScrollDisplay();
				display_at(22-strlen(pobTran->szInputNumber_1), 7, pobTran->szInputNumber_1, CLR_EOL);
			}
		}
	}
	if (pobTran->inOriginalCode == PMT_TRX_BAYAR_PAYID) {
		if (strlen(pobTran->szInputNumber_1)) {
			vdScrollDisplay();
			display_at(1, 7, "KD.INST+NO.CUST", CLR_EOL);
			vdScrollDisplay();
			display_at(22-strlen(pobTran->szInputNumber_1), 7, pobTran->szInputNumber_1, CLR_EOL);
		}
	}

	if (pobTran->inCode == PMT_TRX_BAYAR_CDTCARD) {
		if (strlen(pobTran->szInputNumber_1)) {
			vdScrollDisplay();
			display_at(1, 7, "NO.KARTU KREDIT", CLR_EOL);
			vdScrollDisplay();
			display_at(22-strlen(pobTran->szInputNumber_1), 7, pobTran->szInputNumber_1, CLR_EOL);
		}
		if (pobTran->Total>0) {
			char NumBuff[48];
			vdScrollDisplay();
			memset(buff, 0x00, sizeof(buff));
			memset(NumBuff, 0x00, sizeof(NumBuff));
			FormatNumInd(NumBuff, pobTran->Total);
			NumBuff[12] = 0x00;
			sprintf(buff, "AMT RP. %13s", NumBuff);
			display_at(1, 7, buff, CLR_EOL);
		}
	}

	if (pobTran->inOriginalCode == PMT_TRX_TRANSFER || pobTran->inOriginalCode == PMT_TRX_TRANSFER_REK_LAIN || pobTran->inOriginalCode == PMT_TRX_TRANSFER_BANK_LAIN) {
		if (pobTran->inOriginalCode == PMT_TRX_TRANSFER_BANK_LAIN && strlen(pobTran->szInputNumber_2)) {
			if (atoi(pobTran->szAdditionalInfo)==0) {
				vdScrollDisplay();
				display_at(1, 7, "KD.BANK+NO.REK", CLR_EOL);
				vdScrollDisplay();
				display_at(22-strlen(pobTran->szInputNumber_2), 7, pobTran->szInputNumber_2, CLR_EOL);
			} else {
				char szMenuName[30];
				memset(szMenuName, 0x00, sizeof(szMenuName));
				inGetMenuName(szMenuName, pobTran->inMenuIndex);
				vdScrollDisplay();
				display_at(1, 7, "BANK", CLR_EOL);
				display_at(22-strlen(szMenuName), 7, szMenuName, CLR_EOL);
				vdScrollDisplay();
				display_at(1, 7, "NO.REK", CLR_EOL);
				display_at(22-strlen(pobTran->szInputNumber_2), 7, pobTran->szInputNumber_2, CLR_EOL);
			}
		} else if (strlen(pobTran->szInputNumber_2)) {
			vdScrollDisplay();
			display_at(1, 7, "NO.REK", CLR_EOL);
			display_at(22-strlen(pobTran->szInputNumber_2), 7, pobTran->szInputNumber_2, CLR_EOL);
		}
		if (strlen(pobTran->szInputNumber_3)) {
			vdScrollDisplay();
			display_at(1, 7, "NO.REF", CLR_EOL);
			display_at(22-strlen(pobTran->szInputNumber_3), 7, pobTran->szInputNumber_3, CLR_EOL);
		}
		if (pobTran->Total>0) {
			char NumBuff[48];
			vdScrollDisplay();
			memset(buff, 0x00, sizeof(buff));
			memset(NumBuff, 0x00, sizeof(NumBuff));
			FormatNumInd(NumBuff, pobTran->Total);
			NumBuff[12] = 0x00;
			sprintf(buff, "AMT RP. %13s", NumBuff);
			display_at(1, 7, buff, CLR_EOL);
		}
	}

	return 1;
}

int inGetCard(TRANSACTION_OBJECT *pobTran)
{
	int inResult=0;
	do {
		inResult = inGetCardInside(pobTran);		
		if (inResult==1) return 1;
		if (inResult==-1) return 0;
	} while (1);
	return 1;
}

int inGetCardInside(TRANSACTION_OBJECT *pobTran)
{
    int i;
	short	shRetVal = 0 ;
    char	szRawCardData[CARD_SIZE] ;
	int     kar;

	ClearSevenLine();
	write_at("Enter Card Number or", 20, 1, 4);  //display logo swipe here if needed
	write_at(" Swipe Customer Card", 20, 1, 5);
	TimeOut(15000);
	do {
		if (card_pending()==1) {
			break;
		}
		if (KBHIT()){
			int inKeyPressResult = inGetCardManual(pobTran);
			if (inKeyPressResult==0) { 
				ClearSevenLine(); 
				return 0;
			} else if (inKeyPressResult==-1) {
				return -1;
			}else {
				return inCheckCard(pobTran);
			}
		}
		//if (TimeOut(0)) return 0;
		if (TimeOut(0)) return -1;
		SVC_WAIT(0);
	}while (1);

	shRetVal = read(hMagReader, szRawCardData, sizeof(szRawCardData)) ;
    if(shRetVal < 0)
	{
		//DisplayStatus("Can't read Card Data");
		DisplayStatus("SWIPE ERR. TRY AGAIN");
		vdWarnBeep();
		SVC_WAIT(2000);
		DisplayStatus("");
        return 0 ;
	}
	//parse the card data
	shRetVal = card_parse(szRawCardData, &stParsedCardData, "1") ;
	if (shRetVal == 1) {
		strcpy(pobTran->szCHolder, stParsedCardData.name);
	}
    shRetVal = card_parse(szRawCardData, &stParsedCardData, "2") ;
    if(shRetVal != 2)
	{
		//DisplayStatus("Error in Card Parsing");
		DisplayStatus("SWIPE ERR. TRY AGAIN");
		vdWarnBeep();
  		SVC_WAIT(2000);
		DisplayStatus("");
        return 0 ;
	}
	while (1) {  //trimspace
		if (strlen(pobTran->szCHolder)==0) {
			strcpy(pobTran->szCHolder, "-");
			break;
		} else if (isspace(pobTran->szCHolder[strlen(pobTran->szCHolder)-1])) {
			pobTran->szCHolder[strlen(pobTran->szCHolder)-1] = 0x00;
		} else {
			break;
		}
	}
	strcpy(pobTran->szPAN, stParsedCardData.acct);
	strcpy(pobTran->szExpDate, stParsedCardData.exp);
	if (card_parse(szRawCardData, &stParsedCardData, "2")==2) {
		strcpy(pobTran->stT2Data, stParsedCardData.track);
	} else {
        //DisplayStatus("Invalid Track2 Data");
		DisplayStatus("SWIPE ERR. TRY AGAIN");
		vdWarnBeep();
  		SVC_WAIT(2000);
		DisplayStatus("");
		return 0;
	}
	LOG_PRINTFF((0x08L, "Parsed Track2 (%d) = %s", strlen(stParsedCardData.track), stParsedCardData.track));
	for (i=0; i<7; i++) vdScrollDisplay();
    if (strlen(pobTran->szCHolder)>0) {
		char buff[22];
		display_at(1, 6, "PAN", CLR_EOL);
		display_at(22-strlen(pobTran->szPAN), 6, pobTran->szPAN, CLR_EOL);
		memset(buff, 0x00, sizeof(buff));
		strncat(buff, &pobTran->szExpDate[2], 2);
		strncat(buff, &pobTran->szExpDate[0], 2);
		display_at(1, 7, "EXP.(MMYY)", CLR_EOL);
		display_at(22-strlen(buff), 7, buff, CLR_EOL);
		//vdScrollDisplay();
		//memset(buff, 0x00, sizeof(buff));
		//strncpy(buff, pobTran->szCHolder, 21);
		//display_at(1, 7, "Name", CLR_EOL);
		//display_at(22-strlen(buff), 7, buff, CLR_EOL);
	} else {
		char buff[22];
		display_at(1, 6, "PAN", CLR_EOL);
		display_at(22-strlen(pobTran->szPAN), 6, pobTran->szPAN, CLR_EOL);
		memset(buff, 0x00, sizeof(buff));
		strncat(buff, &pobTran->szExpDate[2], 2);
		strncat(buff, &pobTran->szExpDate[0], 2);
		display_at(1, 7, "EXP.(MMYY)", CLR_EOL);
		display_at(22-strlen(buff), 7, buff, CLR_EOL);
	}
    //display_at(1, 4, "Exp on :", CLR_EOL);
    //display_at(9, 4, stParsedCardData.exp, CLR_EOL);
	return inCheckCard(pobTran);
}

int inGetCardManual(TRANSACTION_OBJECT *pobTran)
{
	char buff[128];
	long Acct;
	int i;

	ClearSevenLine();

	for (i=0; i<obTranMapCount; i++) {
		if (pobTran->inCode == obTranMap[i].inCode) {
			if (obTranMap[i].inManual==0) {
				if (get_char() != 27) {
					DisplayStatus("Swipe Only!");
					SVC_WAIT(1000);
					return 0;
				}
				return -1;  //cancel key pressed
			}
		}
	}

	while (1) {
	   memset(buff, 0x00, sizeof(buff));
	   if (InputPAN("PAN", buff, 1L, (long)9999999999L, 0, &Acct) == 0) return 0;
	   //if (InputNumber("PAN", buff, 1L, (long)9999999999L, 0, &Acct) == 0) return 0;
	   if (strlen(buff)>=12 && strlen(buff)<=PAN_SIZE) {
	      strcpy(pobTran->szPAN, buff);   
		  break;
	   }
	   DisplayStatus("Invalid PAN Input!");
	   SVC_WAIT(500);
	   display_at( 1, 7,"", CLR_EOL);
	   ClearStatusLine();
	}
	vdScrollDisplay();
	while (1) {
	   memset(buff, 0x00, sizeof(buff));
	   if (InputNumberEngl("EXP.(MMYY)", buff, 1L, (long)9999999999L, 0, &Acct) == 0) return 0;
	   if (strlen(buff)==EXP_DATE_SIZE) {
	      strncpy(&pobTran->szExpDate[0], &buff[2], 2);
		  strncpy(&pobTran->szExpDate[2], &buff[0], 2);
		  pobTran->szExpDate[4] = 0x00;
		  break;
	   }
	   DisplayStatus("Must 4 Digit!");
	   SVC_WAIT(500);
	   display_at( 1, 7,"", CLR_EOL);
	   ClearStatusLine();
	}
	pobTran->inManual=1;
	return 1;
}

int inCheckCard(TRANSACTION_OBJECT *pobTran)
{
	char Buff[20];
	char CurrDate[5];
	char CardBin[20];
	int i;
	memset(Buff, 0x00, sizeof(Buff));
	memset(CardBin, 0x00, sizeof(CardBin));
	SVC_CLOCK(0, Buff, 15);
		
	strncpy(CurrDate, &Buff[2], 4);
	CurrDate[4] = 0x00;

	if (strcmp(CurrDate, pobTran->szExpDate)>0) {
		DisplayStatus("EXPIRED CARD!");
		vdWarnBeep();
		SVC_WAIT(1000);
		return 0;
	}
//  bin checking
	pobTran->isOnUs = 0;
	for (i=0; i<20; i++) {
	   memset(Buff, 0x00, sizeof(Buff));
	   get_env_x(HOST_CARD_ONUS, i, Buff);
	   if (!strncmp(Buff, pobTran->szPAN, strlen(Buff))) {
		   pobTran->isOnUs = 1;
		   break;
		  //return 1;
	   }
	}

	if (pobTran->isOnUs==0) {
		memset(Buff, 0x00, sizeof(Buff));
		get_env_x(TXR_OFFUS, 0, Buff);		
		if (atoi(Buff)==0) {
			if (pobTran->inOriginalCode == PMT_TRX_ISI_ULANG
				|| pobTran->inOriginalCode == PMT_TRX_BAYAR_TELPON
				|| pobTran->inOriginalCode == PMT_TRX_BAYAR_PLN
				|| pobTran->inOriginalCode == PMT_TRX_BAYAR_PALYJA
				|| pobTran->inOriginalCode == PMT_TRX_BAYAR_PAM
				|| pobTran->inOriginalCode == PMT_TRX_BAYAR_CDTCARD
				|| pobTran->inOriginalCode == PMT_TRX_CICILAN_ACC
				|| pobTran->inOriginalCode == PMT_TRX_CICILAN_FIF
				|| pobTran->inOriginalCode == PMT_TRX_CICILAN_TAF
				|| pobTran->inOriginalCode == PMT_TRX_CICILAN_SCB
				|| pobTran->inOriginalCode == PMT_TRX_CICILAN_CITI
				|| pobTran->inOriginalCode == PMT_TRX_CICILAN_ADIRA
				|| pobTran->inOriginalCode == PMT_TRX_BAYAR_PENDIDIKAN
				|| pobTran->inOriginalCode == PMT_TRX_BAYAR_ASURANSI
				|| pobTran->inOriginalCode == PMT_TRX_BAYAR_TIKET
				|| pobTran->inOriginalCode == PMT_TRX_BAYAR_PAYID) {
				DisplayStatus("CARD NOT ALLOWED!");
				vdWarnBeep();
				SVC_WAIT(1000);
				return 0;
			}
		}
	}

	if ((strcmp(pobTran->szPAN, "000000")<=0) || (strcmp("99999:", pobTran->szPAN)<=0)) { //()*+'-./0123456789:;<=>?@A...
		DisplayStatus("UNAUTHORIZED CARD!");
		vdWarnBeep();
		SVC_WAIT(1000);
		return 0;
	}
	return 1;
}

int inSelectAccount(TRANSACTION_OBJECT *pobTran)
{
	int RetVal = 0;
	RetVal = inMenuChoice("Select Acct:", "", "Saving", "Current", "");
	if (RetVal==2) pobTran->inAccType = 2;
	if (RetVal==3) pobTran->inAccType = 3;
	return RetVal;
}

int inGetAmount(TRANSACTION_OBJECT *pobTran, char *Msg)
{
	char buff[22];
	long Amt = 0L;
	memset(buff, 0x00, sizeof(buff));
	if (InputNumberInd(Msg, buff, 1L, (long)999999999L, 1, &Amt) == 0) return 0;  //hati-hati batas atas
	pobTran->Amt = Amt;
	pobTran->Total = pobTran->Amt;
	memset(pobTran->szTotal, 0x00, sizeof(pobTran->szTotal));
	sprintf(pobTran->szTotal, "%ld00", pobTran->Total);
	return 1;
}

int inGetAmountForBillPayment(TRANSACTION_OBJECT *pobTran, char *Msg)
{
	char buff[22];
	char szCurrMsg[10];
	long Amt = 0L;
	memset(buff, 0x00, sizeof(buff));
	memset(szCurrMsg, 0x00, sizeof(szCurrMsg));

	strcpy(szCurrMsg, "AMT  ");
	vdGetCurrency(&szCurrMsg[5], &pobTran->szF48[60+F48_ADD_SIZE]);
	szCurrMsg[8]=0x00;

	if (!strcmp(&szCurrMsg[5], "RP.")) {
		if (InputNumberInd(szCurrMsg, buff, 1L, atol(pobTran->szTotal), 1, &Amt) == 0) return 0;  //hati-hati batas atas
		memset(pobTran->szTotal, 0x00, sizeof(pobTran->szTotal));
		sprintf(pobTran->szTotal, "%ld00", Amt);
		pobTran->Amt = Amt;
		pobTran->Total = pobTran->Amt;
	} else {
		if (InputNumberWithCentEngl(szCurrMsg, buff, 1L, atol(pobTran->szTotal), 1, &Amt) == 0) return 0;  //hati-hati batas atas
		memset(pobTran->szTotal, 0x00, sizeof(pobTran->szTotal));
		sprintf(pobTran->szTotal, "%ld", Amt);
		pobTran->Amt = Amt/100L;
		pobTran->Total = pobTran->Amt;
	}
	return 1;
}

int inGetTip(TRANSACTION_OBJECT *pobTran, char *Msg)
{
	char buff[22];
	long Tip = 0L;
	memset(buff, 0x00, sizeof(buff));
	if (InputNumberInd("Tip Rp", buff, 0L, (long)999999999L, 1, &Tip) == 0) return 0;
	pobTran->Tip = Tip;
	pobTran->Total = pobTran->Amt + pobTran->Tip;
	return 1;
}

int inGetPoint(TRANSACTION_OBJECT *pobTran, char *Msg)
{
	char buff[22];
	long Amt = 0L;
	memset(buff, 0x00, sizeof(buff));
	if (InputNumberInd(Msg, buff, 1L, (long)999999999L, 2, &Amt) == 0) return; 

	pobTran->Point = Amt;
	pobTran->Total = pobTran->Point;
	return 1;
}

int inGetGeneralInputNumber_1(TRANSACTION_OBJECT *pobTran, char *Msg, int MinDigit, int MaxDigit)
{
	char buff[22];
	long Amt = 0L;
	memset(buff, 0x00, sizeof(buff));
	if (InputNumberInd(Msg, buff, MinDigit, MaxDigit, 3, &Amt) == 0) return 0;  //hati-hati batas atas
	strcpy(pobTran->szInputNumber_1, buff);
	return 1;
}

int inGetGeneralInputNumber_2(TRANSACTION_OBJECT *pobTran, char *Msg, int MinDigit, int MaxDigit)
{
	char buff[22];
	long Amt = 0L;
	memset(buff, 0x00, sizeof(buff));
	if (InputNumberInd(Msg, buff, MinDigit, MaxDigit, 3, &Amt) == 0) return 0;  //hati-hati batas atas
	strcpy(pobTran->szInputNumber_2, buff);
	return 1;
}

int inGetGeneralInputNumber_3(TRANSACTION_OBJECT *pobTran, char *Msg, int MinDigit, int MaxDigit)
{
	char buff[22];
	long Amt = 0L;
	memset(buff, 0x00, sizeof(buff));
	if (InputNumberInd(Msg, buff, MinDigit, MaxDigit, 3, &Amt) == 0) return 0;  //hati-hati batas atas
	strcpy(pobTran->szInputNumber_3, buff);
	return 1;
}


int inGetVoucherAmt(TRANSACTION_OBJECT *pobTran, char *Msg)
{
	char buff[22];
	long Amt = 0L;
	memset(buff, 0x00, sizeof(buff));
	if (InputNumberInd(Msg, buff, 1L, (long)999999999L, 1, &Amt) == 0) return 0;  //hati-hati batas atas
	pobTran->lnVoucherAmt = Amt;
	return 1;
}

/*
int inGetRcptAcc(TRANSACTION_OBJECT *pobTran, char *Ket)
{
	char buff[22];
	long Acct;
	memset(buff, 0x00, sizeof(buff));
	if (InputNumber(Ket, buff, 1L, (long)9999999999L, 0, &Acct) == 0) return 0;
	strcpy(pobTran->szRcptAcc, buff);
	return 1;
}
*/

int inGetEncryptedPin(TRANSACTION_OBJECT *pobTran, char *Msg)
{
	char buff[20];
	memset(buff, 0x00, sizeof(buff));

	if ((memcmp(buff, pobTran->szPIN, 8)) && (memcmp(buff, pobTran->szPIN2, 8))) {
		memcpy(buff, pobTran->szPIN, 8);
		if (inGetPinAccMac(pobTran, Msg)==VS_SUCCESS) {
			if (strncmp(pobTran->szPIN, pobTran->szPIN2,16)) {
				DisplayStatus("Konfirmasi Gagal!");
				SVC_WAIT(1000);
				return 0;
			} else {
				memset(pobTran->szPIN, 0x00, sizeof(pobTran->szPIN));
				memcpy(pobTran->szPIN, buff, 8);
				return 1;
			}
		}
	} else if (memcmp(buff, pobTran->szPIN, 8)) {
		memcpy(buff, pobTran->szPIN, 8);
		if (inGetPinAccMac(pobTran, Msg)==VS_SUCCESS) {
			strncpy(pobTran->szPIN2, pobTran->szPIN, 16);
			memset(pobTran->szPIN, 0x00, sizeof(pobTran->szPIN));
			memcpy(pobTran->szPIN, buff, 8);
			return 1;
		}
	} else {
		if (inGetPinAccMac(pobTran, Msg)==VS_SUCCESS) {
			char buff[30];
			{//SVC_DSP_2_HEX(pobTran->szPIN, pobTran->szPIN, 8);  //asc to bcd
				memset(buff, 0x00, sizeof(buff));
				SVC_DSP_2_HEX(pobTran->szPIN, buff, 8);  //asc to bcd
				memset(pobTran->szPIN, 0x00, sizeof(pobTran->szPIN));
				memcpy((char *)pobTran->szPIN, buff, 8);
			}
			//memset(pobTran->szPIN2, 0x00, sizeof(pobTran->szPIN2));
			return 1;
		}
	}
    return 0;
}

int inCallZontalk(char chZonType)
{
    int inRes = 0;

   	inRes = SVC_ZONTALK(chZonType);
	LOG_PRINTFF((0x08L, "SVC_ZONTALK(%c) return [%d]", chZonType, inRes));
	if (inRes > 0) {
		switch (inRes) {
			case NO_CARRIER:
				DisplayStatus("No Carrier");
				break;
			case BUSY_DETECT:
				DisplayStatus("Busy");
				break;
			case NO_DIALTONE:
				DisplayStatus("No Dialtone");
				break;
			default:
				DisplayStatus("Comm Failure");
		}
		vdWarnBeep();
		SVC_WAIT(2000);
	}
	if (inRes < 0) {
		DisplayStatus("Comm Failure");
		vdWarnBeep();
		SVC_WAIT(2000);
	}
	if (inRes == 0) {
		DisplayStatus("Download Success");
		SVC_WAIT(1000);
	}
    return(inRes);
}

/////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
void VIP_Lounge(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];

	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));
	clrscrplus("* Executive Lounge *");
	memset((char *)&obTran, 0x00, sizeof(obTran));
	pobTran->inCode = TRX_INFO_SALDO;
	if (inGetCard(pobTran)==0) return;
	vdScrollDisplay();
	if (inCheckCard(pobTran)==0) return;
	if (inBeginComm()==0) return;
	if (inGetPoint(pobTran, "Pax No")==0) return;
	vdScrollDisplay();
	DisplayStatus("Processing...");
	if (SaveNewBatchRecord(pobTran)<=0) return;	
	DisplayStatus("Processing...");
	if (SetBitmap(pobTran)<=0) return;
	if (PackMessage(pobTran, SentBuff)<=0) return;
	if (SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 1)<=0) return;  //0 ==> no reversal mechanism inside
	if (UnpackAndValidateMessage(pobTran, RecvBuff)<=0) return;
	if (SaveBatchRecordAfterTrx(pobTran)<=0) return;
	PrintResponse(pobTran);
}

void Void(TRANSACTION_OBJECT *pobTran)
{
	char buff[22];
	long lnInv = 0;
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];

	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));
	clrscrplus("* V O I D *");
	memset((char *)&obTran, 0x00, sizeof(obTran));
	memset(buff, 0x00, sizeof(buff));
	if (InputNumberInd("Inv #:", buff, 1L, 999999L, 2, &lnInv) == 0) return;  //hati-hati batas atas
	if (ChooseBatchRecord((unsigned long)lnInv, 2, pobTran)==0) return; 
	if (pobTran->Status==3) {
		DisplayStatus("Voided! but pending");
		vdScrollDisplay();
		DisplayStatus("Must Send Reversal!");
		SVC_WAIT(2000);
		return;
	}
	if (inBeginComm()==0) return;
	DisplayStatus("Processing...");
	if (SetBitmap(pobTran)<=0) return;
	if (PackMessage(pobTran, SentBuff)<=0) return;
	if (SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 1)<=0) return;  //reversal mechanism inside
	if (UnpackAndValidateMessage(pobTran, RecvBuff)<=0) return;
	if (SaveBatchRecordAfterTrx(pobTran)<=0) return;
	PrintResponse(pobTran);
}

void AnzPayment(TRANSACTION_OBJECT *pobTran)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];

	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));
	clrscrplus("* ANZ Payment *");

	memset((char *)&obTran, 0x00, sizeof(obTran));
	pobTran->inCode = TRX_TRANSFER;
	if (inGetCard(pobTran)==0) return;
	vdScrollDisplay();
	if (inCheckCard(pobTran)==0) return;
	if (inBeginComm()==0) return;
	if (inGetAmount(pobTran, "Amt Rp")==0) return;
	vdScrollDisplay();
	DisplayStatus("Processing...");
	if (SaveNewBatchRecord(pobTran)<=0) return;	
	DisplayStatus("Processing...");
	if (SetBitmap(pobTran)<=0) return;
	if (PackMessage(pobTran, SentBuff)<=0) return;
	if (SendAndReceiveMessage(pobTran, SentBuff, RecvBuff, 1)<=0) return;  //reversal mechanism inside
	if (UnpackAndValidateMessage(pobTran, RecvBuff)<=0) return;
	if (SaveBatchRecordAfterTrx(pobTran)<=0) return;
	PrintResponse(pobTran);
}

void ReprintLastTransaction(TRANSACTION_OBJECT *pobTran)
{	
	long lnSTAN = 0;
	//clrscrplus("* Last Receipt *");
	memset((char *)&obTran, 0x00, sizeof(obTran));
	if (ChooseBatchRecord(0, 2, pobTran)==0) return;  //lnSTAN=0 for last trxn
	DisplayStatus("Printing...");
	RePrintResponse(pobTran);
}

void ReprintAnyTransaction(TRANSACTION_OBJECT *pobTran)
{	
	char buff[22];
	long lnInv = 0;
	//clrscrplus("* Any Receipt *");
	memset((char *)&obTran, 0x00, sizeof(obTran));
	memset(buff, 0x00, sizeof(buff));

	if (InputNumberInd("Trace/Inv #:", buff, 1L, (long)999999L, 2, &lnInv) == 0) return; 
	if (ChooseBatchRecord((unsigned long)lnInv, 2, pobTran)==0) return;
	DisplayStatus("Printing...");
	RePrintResponse(pobTran);
}

void SummaryReport(TRANSACTION_OBJECT *pobTran)
{
	clrscrplus("* Summary Report *");
	memset((char *)&obTran, 0x00, sizeof(obTran));
	PrintSummaryReport("");
}

void DetailReport(TRANSACTION_OBJECT *pobTran)
{
	clrscrplus("* Detail Report *");
	memset((char *)&obTran, 0x00, sizeof(obTran));
	PrintDetailReport("");
}

void PastReport(TRANSACTION_OBJECT *pobTran)
{
	char buff[22];
	long lnNum;

	clrscrplus("* Past Report *");
	memset((char *)&obTran, 0x00, sizeof(obTran));

	memset(buff, 0x00, sizeof(buff));
	if (InputNumberInd("Date (DDMMYY): ", buff, 1L, (long)9999999999L, 0, &lnNum) == 0) return;
	if (strlen(buff) == 6) {
		if ((strncmp(&buff[0], "31", 2)>0) || (strncmp(&buff[2], "12", 2)>0)) {
			DisplayStatus("Invalid Date!");
			vdWarnBeep();
			SVC_WAIT(1000);
			return;
		}
	} else {
		DisplayStatus("Invalid Date!");
		vdWarnBeep();
		SVC_WAIT(1000);
		return;
	}
	strncpy(&buff[6], &buff[2], 2);
	strncpy(&buff[8], &buff[0], 2);
	strncpy(&buff[0], &buff[4], 6);
	buff[6] = 0x00;
    PrintDetailReport(buff);
	PrintSummaryReport(buff);
}

int BeginSetup() 
{
   clrscrplus("* Setup *");
   return GetAndVerifyPassword();
}

int DoSetPriAuthPhone()
{
    char buff[128];
	clrscrplus("* Set Primary Phone *");
	memset(buff, 0x00, sizeof(buff));
	get_env_x(HOST_COMM, 0, buff);
	write_at("Primary Auth Phone:", 19, 1, 4);
	write_at(buff, strlen(buff), 1, 5);
	memset(buff, 0x00, sizeof(buff));
	if (InputString("New : ", buff)!=-1) {
		if (put_env_x(HOST_COMM, 0, buff) != -1) {
			DisplayStatus("PriAuthPhone Set!");
			SVC_WAIT(1000);
			return 1;
		}
	}
	return 0;
}

int DoSetSecAuthPhone()
{
    char buff[128];
	clrscrplus("* Set Second Phone *");
	memset(buff, 0x00, sizeof(buff));
	get_env_x(HOST_COMM, 1, buff);
	write_at("Secondary Auth Phone:", 21, 1, 4);
	write_at(buff, strlen(buff), 1, 5);
	memset(buff, 0x00, sizeof(buff));
	if (InputString("New : ", buff)!=-1) {
		if (put_env_x(HOST_COMM, 1, buff) != -1) {
			DisplayStatus("SecAuthPhone Set!");
			SVC_WAIT(1000);
			return 1;
		}
	}
	return 0;
}

int DoChangeBIN()
{
    char buff[128];
	clrscrplus("* Set BIN *");
	memset(buff, 0x00, sizeof(buff));
	if (get_env("BIN", buff, sizeof(buff)-1)>0) {
	   write_at("BIN: ", 5, 1, 4);
	   write_at(buff, strlen(buff), 1, 5);
	   memset(buff, 0x00, sizeof(buff));
	   if (InputString("New: ", buff)!=-1) {
		  if (put_env("BIN", buff, strlen(buff)) != -1) {
			  DisplayStatus("New BIN Set!");
			  SVC_WAIT(1000);
			  return 1;
		  }
	   }
	}
	return 0;
}

int DoChangePassword()
{
   clrscrplus("* Change Password *");
   return ChangePassword();
}

void ReportBatch(TRANSACTION_OBJECT *pobTran)
{
	clrscrplus("* Report *");
	DisplayStatus("Not Available Yet");
	SVC_WAIT(1000);
	//VoidVIP_Lounge(pobTran);
}


/*
int inDisplayRcptName(TRANSACTION_OBJECT *pobTran, char *Ket)
{
	char buff[22];
	memset(buff, 0x00, sizeof(buff));
	pobTran->szRcptName[21-strlen(Ket)-1] = 0x00;
	strcpy(buff, Ket);
	strncat(buff, "                        ", 21-strlen(Ket)-strlen(pobTran->szRcptName));
	strcat(buff, pobTran->szRcptName);
	write_at(buff, strlen(buff), 1, 7);
    return 1;
}
*/

int DisplayTotal(TRANSACTION_OBJECT *pobTran)
{
	char buff[22];
	char buffDest[30];

	memset(buffDest, 0x00, sizeof(buffDest));
	pobTran->Total = pobTran->Amt + pobTran->Tip;
	if (pobTran->Total < pobTran->Amt || pobTran->Total < pobTran->Tip) {
		DisplayStatus("Out of Range!");
		vdWarnBeep();
		SVC_WAIT(2000);
		DisplayStatus("");
		return 0;
	}
	sprintf(buff, "%ld", pobTran->Total);
	write_at("Total RP", 8, 1, 7);
	FormatNumberInd(buffDest, buff);
	write_at(buffDest, strlen(buffDest), 22-strlen(buffDest), 7);
	return 1;
}

int GetPin(TRANSACTION_OBJECT *pobTran)
{
	int karakter=0;
	char Number[8];
	char PassNum[8];
	memset(Number, 0x00, sizeof(Number));
	memset(PassNum, 0x00, sizeof(PassNum));
	memset(PassNum, '*', sizeof(PassNum)-1);
	display_at(1, 7, "Enter PIN", CLR_EOL);
	write_at("_", 1, 21, 7);
	vdFlushKeyboardBuffer();
	do {
		karakter = get_char();
		if (karakter >= 0x30 && karakter <= 0x39) {
			if (strlen(Number)<6) {
				Number[strlen(Number)] = karakter;
				write_at(PassNum, strlen(Number), 22-strlen(Number), 8);
			}
		} else if (karakter==8) {
			if (strlen(Number)>0) {
				Number[strlen(Number)-1] = 0x00;
				display_at(1, 7, "Enter PIN", CLR_EOL);
				write_at(PassNum, strlen(Number), 22-strlen(Number), 8);
			}
		} else if (karakter==13){
			if (strlen(Number)<=6 && strlen(Number)>=4) {
				strcpy(pobTran->szPIN, Number); 
				return 1;
			}
		} else if (karakter==27){
			return 0;
		}
	} while (1);
	return 1;
}


int SendAndReceiveMessage(TRANSACTION_OBJECT *pobTran, unsigned char *SentBuff, unsigned char *RecvBuff, int Reversal)
{
    int inRetVal = 0;                               
	unsigned char buff[MSG_BUFF_SIZE+1];
	int SentSize = SentBuff[0]*256 + SentBuff[1];
	int RecvSize = 0;

	//SVC_WAIT(3000);
    if (obCommunication.inCheck){
        if (obCommunication.inCheck(&obCommunication) != VS_SUCCESS){
            DisplayStatus("Not Connected!");
			return 0;
        }
    }
	memset(buff, 0x00, sizeof(buff));
	memcpy((char *)buff, (char *)SentBuff, SentSize+2);
	LOG_PRINTFF((0x08L, "inReqSiz is (%d-2)", SentSize+2));
	LOG_PRINT_HEX(buff, SentSize+2);

//#ifdef __arm
	if ((fAES()) && (obCommunication.inLinkType!=8)) { // encrypt data
		unsigned long ticks;
		unsigned char szSendBuffTmp[1024];
		int inSendSizeTmp = SentSize+2;
		int iRet;
		memset(szSendBuffTmp, 0x00, sizeof(szSendBuffTmp));
		memcpy(szSendBuffTmp, (char *)SentBuff, inSendSizeTmp);
		memset(SentBuff, 0x00, sizeof(SentBuff));
		ticks = read_ticks();
		iRet = inPvsAesEncrypt(szSendBuffTmp, inSendSizeTmp, SentBuff, &SentSize);
		memmove(&SentBuff[2], SentBuff, SentSize);
		SentBuff[0] = SentSize/256;
		SentBuff[1] = SentSize%256;
		//SendSize = SendSize + 2;
		LOG_PRINTFF((0x08L, "AES Encrypt Time Taken = [%ld ms]", read_ticks()-ticks));
		if (iRet != 0)
			return -1;  //encrypt err
	}
//#endif

    if (obCommunication.inSend) {
		BT_REQUEST_TRACE('B', &SentBuff[2], SentSize);
		if (FindAndSendReversal()<=0) {
			DisplayStatus("Reversal Fail!");
			SVC_WAIT(2000);
			obCommunication.inEnd(&obCommunication);
			LOG_PRINTFF((0x08L, "Error in Process Reversal!!!"));
			return 0;
		}
		if (obCommunication.inLinkType == 1 || obCommunication.inLinkType == 3 || obCommunication.inLinkType == 8 || obCommunication.inLinkType == 9)  {
			inRetVal = obCommunication.inSend(&obCommunication, (char *)&SentBuff[2], SentSize, VS_TRUE, inGetSendTimeOut() /*SEND_COMM_TIMEOUT*/, MSG_TRANSMITTING);
		} else {
			SentSize = SentSize + 2;
			inRetVal = obCommunication.inSend(&obCommunication, (char *)SentBuff, SentSize, VS_TRUE, inGetSendTimeOut() /*SEND_COMM_TIMEOUT*/, MSG_TRANSMITTING);            
		}
        if ((inRetVal == E_NOCARRIER) ||(inRetVal == E_X_NOCARRIER) || (inRetVal == VS_CARRIER)) {
			DisplayStatus("No Carrier!");
			obCommunication.inEnd(&obCommunication);
			return 0;
        }
		if (Reversal) {
			SaveBatchRecordForReversal(pobTran);
		}
		if (inRetVal != SentSize){
			DisplayStatus("Sending Message Fail!");        
			obCommunication.inEnd(&obCommunication);
			return 0;
		}
		if (inEnablePrintISOTrace()) {
			memset(buff, 0x00, sizeof(buff));
			memcpy((char *)buff, (char *)&SentBuff[2], SentSize);
			LOG_PRINT_RCPT("SND:");
			LOG_PRINT_RCPT_HEX(buff, SentSize);
		}
    }
    if (obCommunication.inReceive) {
		if (obCommunication.inLinkType == 1 || obCommunication.inLinkType == 3 || obCommunication.inLinkType == 8 || obCommunication.inLinkType == 9)  {
			inRetVal = obCommunication.inReceive(&obCommunication, (char *)&RecvBuff[2], MSG_BUFF_SIZE-3, inGetRecvTimeOut() /*RECV_COMM_TIMEOUT*/, MSG_RECEIVING);
		} else {
			inRetVal = obCommunication.inReceive(&obCommunication, (char *)RecvBuff, MSG_BUFF_SIZE-3, inGetRecvTimeOut() /*RECV_COMM_TIMEOUT*/, MSG_RECEIVING);
		}
		if (inRetVal>0) RecvSize=inRetVal; //this line for UCL only
	}

    if (obCommunication.inSendReceive) {
		if (FindAndSendReversal()<=0) {
			DisplayStatus("Reversal Fail!");
			SVC_WAIT(2000);
			LOG_PRINTFF((0x08L, "Error in Processing Reversal"));
			obCommunication.inEnd(&obCommunication);
			return 0;
		}
		if (Reversal) {
			if (SaveBatchRecordForReversal(pobTran)<=0) {
				LOG_PRINTFF((0x08L, "Error in Saving Reversal"));
				obCommunication.inEnd(&obCommunication);
				return 0;
			}
		}
        inRetVal = obCommunication.inSendReceive((char *)&SentBuff[2], SentSize, (char *)&RecvBuff[2], &RecvSize);
	}
	//SVC_WAIT(3000);
	LOG_PRINTFF((0x08L, "inRetVal is (%d)", inRetVal));
	LOG_PRINTFF((0x08L, "RecvSize is (%d)", RecvSize));
    if((inRetVal == E_NOCARRIER) ||(inRetVal == E_X_NOCARRIER) || (inRetVal == VS_CARRIER)) {
		FindAndSendReversal();
		DisplayStatus("Lost Carrier!");
		vdWarnBeep();
		SVC_WAIT(2000);
    } else if (inRetVal <= 0 || inRetVal != RecvSize) {
		FindAndSendReversal();
		DisplayStatus("Com Error!");
		vdWarnBeep();
		SVC_WAIT(2000);
    } else {
//#ifdef __arm
		if (fAES() && (obCommunication.inLinkType!=8) && (inRetVal>10)) { // decrypt data
			unsigned char szRecvBuffTmp[1024];
			int inRecvSizeTmp = inRetVal-2;
			int iRet;
			memset(szRecvBuffTmp, 0x00, sizeof(szRecvBuffTmp));
			memcpy(szRecvBuffTmp, &RecvBuff[2], inRecvSizeTmp);
			memset(RecvBuff, 0x00, sizeof(RecvBuff));	
			iRet = inPvsAesDecrypt(szRecvBuffTmp, inRecvSizeTmp, RecvBuff, &RecvSize);
			LOG_PRINTFF((0x08L, "[DECRYPTED (%d)]", RecvSize));
			LOG_PRINT_HEX((unsigned char *)RecvBuff, RecvSize);
			inRetVal = RecvSize;
			if (iRet != 0)
				return -1;  //decrypt err
		} 
//#endif
		if (obCommunication.inLinkType == 1 || obCommunication.inLinkType == 3 || obCommunication.inLinkType == 8 || obCommunication.inLinkType == 9)  { 
			RecvBuff[0] = (inRetVal) / 256;
			RecvBuff[1] = (inRetVal) % 256;
		} else {
			RecvBuff[0] = (inRetVal-2) / 256; //temporary for BCD type host
			RecvBuff[1] = (inRetVal-2) % 256;
		}
		memset(buff, 0x00, sizeof(buff));
		memcpy((char *)buff, (char *)RecvBuff, RecvSize);
		LOG_PRINTFF((0x08L,     "inTxRx8583, NoOfBytes = %d", inRetVal));
		LOG_PRINT_HEX(buff, RecvSize);
		if (inEnablePrintISOTrace()) {
			memset(buff, 0x00, sizeof(buff));
			memcpy((char *)buff, (char *)&RecvBuff[2], RecvSize);
			LOG_PRINT_RCPT("RCV:");
			LOG_PRINT_RCPT_HEX(buff, RecvSize);
		}
	}
	return inRetVal;
}

/*
int GetConfirm(TRANSACTION_OBJECT *pobTran, char *Msg)
{
	char buff[30];
	char buff_res[30];
	if (strcmp(pobTran->szRespCode, "00")) return 0;
	clrscr();
	inShowTitle(pobTran);
	if (strlen(Msg)) write_at(Msg, strlen(Msg), 1, 3);
	if (strlen(pobTran->szRcptName)) {
		write_at(pobTran->szRcptName, (strlen(pobTran->szRcptName)>16)?16:strlen(pobTran->szRcptName), 1, 4);
	}
	write_at(pobTran->szRcptAcc, strlen(pobTran->szRcptAcc), 1, 5);

	memset(buff, 0x00, sizeof(buff));
	sprintf(buff, "%ld", pobTran->Total);
	memmove(&buff[3], buff, strlen(buff));

	memset(buff_res, 0x00, sizeof(buff_res));
	FormatNumber(buff_res, &buff[3]);
	write_at("Rp ", 3 , 1, 6);
	write_at(buff_res, strlen(buff_res), 4, 6);
	write_at("diteruskan?", 11, 1, 7);
	return YesNoChoice("","", 0);
}
*/
int	PrintResponse(TRANSACTION_OBJECT *pobTran)
{
	int inPrintTimes = 0;
	int inChoice = 0;

	inPrintTimes = inGetPrintTimes();
	if (!strcmp(pobTran->szRespCode, "00")) {
		do {
			DisplayStatus("Printing...!");
			pobTran->inReceiptCopy = 1;  //merchant copy
			PrintRcpt(pobTran);
			inPrintTimes--;
			if (inPrintTimes)
				inChoice = inMenuChoice("Print Again?", "", " Yes", "No", "");
		} while (inPrintTimes && inChoice==2);
		return 1;
	} else {
		return 0;
	}

/*
	if (!strcmp(pobTran->szRespCode, "00")) {
		DisplayStatus("Printing...!");
		pobTran->inReceiptCopy = 1;  //merchant copy
		PrintRcpt(pobTran);
*/
/*
		if (YesNoChoice("Print", "Bank Copy?", 1)) {
		   DisplayStatus("Printing...!");
		   pobTran->inReceiptCopy = 2;  //bank copy
		   PrintRcpt(pobTran);
		}
		if (YesNoChoice("Print", "Customer Copy?", 1)) {
		   DisplayStatus("Printing...!");
		   pobTran->inReceiptCopy = 3;  //customer copy
		   PrintRcpt(pobTran);
		}
*/
}

int	inDisplayResponse(TRANSACTION_OBJECT *pobTran, unsigned long lnShowTime)
{
	char hrf[20];
	char buff[60];
	char buff2[60];
	char szCurr[5];
	
	if (strcmp(pobTran->szRespCode, "00") && strcmp(pobTran->szRespCode, "55")) return 0;

	memset(buff, 0x00, sizeof(buff));
	memset(hrf, 0x00, sizeof(hrf));
	get_font(hrf);
	set_font("");
	ClearSevenLine();
	if (pobTran->inCode==PMT_TRX_TIN  ||  pobTran->inCode==PMT_TRX_PIN_CHANGE) {
		if (strlen(pobTran->szF63)) {
			display_at(1, 4, pobTran->szF63, CLR_EOL);
		} else {
			display_at(1, 4, "Approved", CLR_EOL);
			display_at(10, 4, pobTran->szAuthCode, CLR_EOL);
		}
		display_at(1, 5, "Transaksi Selesai", CLR_EOL);
	} else if (pobTran->inCode==PMT_TRX_INFO_SALDO || pobTran->inCode==PMT_TRX_MINI_STATEMENT){
		if (strlen(pobTran->szPAN)) {
			display_at(1, 3, "PAN", CLR_EOL);
			display_at(22-strlen(pobTran->szPAN), 3, pobTran->szPAN, CLR_EOL);
		}
		if (strlen(pobTran->szExpDate)) {
			memset(buff, 0x00, sizeof(buff));
			strncat(buff, &pobTran->szExpDate[2], 2);
			strncat(buff, &pobTran->szExpDate[0], 2);
			display_at(1, 4, "EXP.(MMYY)", CLR_EOL);
			display_at(22-strlen(buff), 4, buff, CLR_EOL);
		}
		memset(szCurr, 0x00, sizeof(szCurr));
		display_at(1, 5, "SALDO", CLR_EOL);
		if (strlen(pobTran->szTotal)==0) {
			memset(pobTran->szTotal, 0x00, sizeof(pobTran->szTotal));
			strncpy(pobTran->szTotal, &pobTran->szF54[6], 17);
			vdUpdateLnTotal(pobTran);
		}
		memset(buff, 0x00, sizeof(buff));
		FormatNumberWithCentInd(buff, pobTran->szTotal);
		vdGetCurrency(szCurr, &pobTran->szF54[2]);
		display_at(1, 6, szCurr, CLR_EOL);
		display_at(4, 6, buff, CLR_EOL);
	} else if (pobTran->inCode == PMT_TRX_INFO_CDTCARD) {
		char buff_res[30];

		display_at(1, 2, "NAMA", CLR_EOL);
		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[30], 30);
		vdTrimSpace(buff);
		buff[16] = 0x00;
		display_at(22-strlen(buff), 2, buff ,CLR_EOL);

		display_at(1, 3, "NO.", CLR_EOL);
		display_at(22-strlen(pobTran->szInputNumber_1), 3, pobTran->szInputNumber_1, CLR_EOL);

		memset(buff, 0x00, sizeof(buff));
		memset(buff_res, 0x00, sizeof(buff_res));
		strncpy(buff, &pobTran->szF48[60], 8);
		FormatDate(buff_res, buff);
		display_at(1, 4, "JTH TEMPO", CLR_EOL);
		display_at(22-strlen(buff_res), 4, buff_res ,CLR_EOL);

		memset(buff, 0x00, sizeof(buff));
		memset(buff_res, 0x00, sizeof(buff_res));
		strncpy(buff, &pobTran->szF48[69], 12);
		FormatNumberInd(buff_res, buff);
		display_at(1, 5, "BYR MIN", CLR_EOL);
		display_at(22-strlen(buff_res), 5, buff_res ,CLR_EOL);
		memset(buff, 0x00, sizeof(buff));
		memset(buff_res, 0x00, sizeof(buff_res));
		strncpy(buff, &pobTran->szF48[69+15], 12);
		FormatNumberInd(buff_res, buff);
		display_at(1, 6, "TOTAL TAG", CLR_EOL);
		display_at(22-strlen(buff_res), 6, buff_res ,CLR_EOL);
		memset(buff, 0x00, sizeof(buff));
		memset(buff_res, 0x00, sizeof(buff_res));
		strncpy(buff, &pobTran->szF48[69+30], 12);
		FormatNumberInd(buff_res, buff);
		display_at(1, 7, "PEMAKAIAN", CLR_EOL);
		display_at(22-strlen(buff_res), 7, buff_res ,CLR_EOL);
		memset(buff, 0x00, sizeof(buff));
		memset(buff_res, 0x00, sizeof(buff_res));
		strncpy(buff, &pobTran->szF48[69+45], 12);
		FormatNumberInd(buff_res, buff);
		display_at(1, 8, "SISA", CLR_EOL);
		display_at(22-strlen(buff_res), 8, buff_res ,CLR_EOL);
	} else if (pobTran->inOriginalCode == PMT_TRX_BAYAR_TELPON) {
		display_at(1, 4, "TELP/HP", CLR_EOL);
		display_at(22-strlen(pobTran->szInputNumber_1), 4, pobTran->szInputNumber_1, CLR_EOL);

		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE], 20);
		vdTrimSpace(buff);
		display_at(1, 5, "NAMA", CLR_EOL);
		buff[16] = 0x00;
		display_at(22-strlen(buff), 5, buff ,CLR_EOL);

		memset(buff, 0x00, sizeof(buff));
		memset(buff2, 0x00, sizeof(buff2));
		memset(szCurr, 0x00, sizeof(szCurr));
		if (strlen(pobTran->szTotal)==0) {
			memset(pobTran->szTotal, 0x00, sizeof(pobTran->szTotal));
			strncpy(pobTran->szTotal, &pobTran->szF48[63+F48_ADD_SIZE], 12);
			vdUpdateLnTotal(pobTran);
		}
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		if (!strcmp(szCurr, "RP.")) {
			memset(buff, 0x00, sizeof(buff));
			strcpy(buff, pobTran->szTotal);
			if (strlen(buff)>=2) {
				buff[strlen(buff)-2] = 0x00;
			}
			FormatNumberInd(buff2, buff);
		} else {
			FormatNumberWithCentEngl(buff2, pobTran->szTotal);
		}
		display_at(1, 6, "BILL", CLR_EOL);
		display_at(6, 6, szCurr, CLR_EOL);
		display_at(22-strlen(buff2), 6, buff2,CLR_EOL);
	} else if (pobTran->inOriginalCode == PMT_TRX_BAYAR_PLN) {
		char buff_res[30];
		display_at(1, 4, "NO.PLN", CLR_EOL);
		display_at(22-strlen(pobTran->szInputNumber_1), 4, pobTran->szInputNumber_1, CLR_EOL);

		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE], 20);
		vdTrimSpace(buff);
		display_at(1, 5, "NAMA", CLR_EOL);
		buff[16] = 0x00;
		display_at(22-strlen(buff), 5, buff ,CLR_EOL);

		memset(buff, 0x00, sizeof(buff));
		memset(buff2, 0x00, sizeof(buff2));
		memset(szCurr, 0x00, sizeof(szCurr));
		if (strlen(pobTran->szTotal)==0) {
			memset(pobTran->szTotal, 0x00, sizeof(pobTran->szTotal));
			strncpy(pobTran->szTotal, &pobTran->szF48[63+F48_ADD_SIZE], 12);
			vdUpdateLnTotal(pobTran);
		}
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		if (!strcmp(szCurr, "RP.")) {
			memset(buff, 0x00, sizeof(buff));
			strcpy(buff, pobTran->szTotal);
			if (strlen(buff)>=2) {
				buff[strlen(buff)-2] = 0x00;
			}
			FormatNumberInd(buff2, buff);
		} else {
			FormatNumberWithCentEngl(buff2, pobTran->szTotal);
		}
		display_at(1, 6, "BILL", CLR_EOL);
		display_at(6, 6, szCurr, CLR_EOL);
		display_at(22-strlen(buff2), 6, buff2,CLR_EOL);
	} else if (pobTran->inOriginalCode == PMT_TRX_BAYAR_PALYJA) {
		char buff_res[30];
		display_at(1, 4, "NO.PALYJA", CLR_EOL);
		display_at(22-strlen(pobTran->szInputNumber_1), 4, pobTran->szInputNumber_1, CLR_EOL);

		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE], 20);
		vdTrimSpace(buff);
		display_at(1, 5, "NAMA", CLR_EOL);
		buff[16] = 0x00;
		display_at(22-strlen(buff), 5, buff ,CLR_EOL);
		memset(buff, 0x00, sizeof(buff));
		memset(buff2, 0x00, sizeof(buff2));
		memset(szCurr, 0x00, sizeof(szCurr));
		if (strlen(pobTran->szTotal)==0) {
			memset(pobTran->szTotal, 0x00, sizeof(pobTran->szTotal));
			strncpy(pobTran->szTotal, &pobTran->szF48[63+F48_ADD_SIZE], 12);
			vdUpdateLnTotal(pobTran);
		}
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		if (!strcmp(szCurr, "RP.")) {
			memset(buff, 0x00, sizeof(buff));
			strcpy(buff, pobTran->szTotal);
			if (strlen(buff)>=2) {
				buff[strlen(buff)-2] = 0x00;
			}
			FormatNumberInd(buff2, buff);
		} else {
			FormatNumberWithCentEngl(buff2, pobTran->szTotal);
		}
		display_at(1, 6, "BILL", CLR_EOL);
		display_at(6, 6, szCurr, CLR_EOL);
		display_at(22-strlen(buff2), 6, buff2,CLR_EOL);
	} else if (pobTran->inOriginalCode == PMT_TRX_BAYAR_PAM) {
		char buff_res[30];
		display_at(1, 4, "NO.PAM", CLR_EOL);
		display_at(22-strlen(pobTran->szInputNumber_1), 4, pobTran->szInputNumber_1, CLR_EOL);

		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE], 20);
		vdTrimSpace(buff);
		display_at(1, 5, "NAMA", CLR_EOL);
		buff[16] = 0x00;
		display_at(22-strlen(buff), 5, buff ,CLR_EOL);

		memset(buff, 0x00, sizeof(buff));
		memset(buff2, 0x00, sizeof(buff2));
		memset(szCurr, 0x00, sizeof(szCurr));
		if (strlen(pobTran->szTotal)==0) {
			memset(pobTran->szTotal, 0x00, sizeof(pobTran->szTotal));
			strncpy(pobTran->szTotal, &pobTran->szF48[63+F48_ADD_SIZE], 12);
			vdUpdateLnTotal(pobTran);
		}
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		if (!strcmp(szCurr, "RP.")) {
			memset(buff, 0x00, sizeof(buff));
			strcpy(buff, pobTran->szTotal);
			if (strlen(buff)>=2) {
				buff[strlen(buff)-2] = 0x00;
			}
			FormatNumberInd(buff2, buff);
		} else {
			FormatNumberWithCentEngl(buff2, pobTran->szTotal);
		}
		display_at(1, 6, "BILL", CLR_EOL);
		display_at(6, 6, szCurr, CLR_EOL);
		display_at(22-strlen(buff2), 6, buff2,CLR_EOL);
	} else if (pobTran->inOriginalCode == PMT_TRX_CICILAN_ACC) {
		char buff_res[30];
		display_at(1, 3, "NO.KONTRAK", CLR_EOL);
		display_at(22-strlen(pobTran->szInputNumber_1), 4, pobTran->szInputNumber_1, CLR_EOL);

		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE], 20);
		vdTrimSpace(buff);
		display_at(1, 5, "NAMA", CLR_EOL);
		buff[16] = 0x00;
		display_at(22-strlen(buff), 5, buff ,CLR_EOL);

		memset(buff, 0x00, sizeof(buff));
		memset(buff2, 0x00, sizeof(buff2));
		memset(szCurr, 0x00, sizeof(szCurr));
		if (strlen(pobTran->szTotal)==0) {
			memset(pobTran->szTotal, 0x00, sizeof(pobTran->szTotal));
			strncpy(pobTran->szTotal, &pobTran->szF48[63+F48_ADD_SIZE], 12);
			vdUpdateLnTotal(pobTran);
		}
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		if (!strcmp(szCurr, "RP.")) {
			memset(buff, 0x00, sizeof(buff));
			strcpy(buff, pobTran->szTotal);
			if (strlen(buff)>=2) {
				buff[strlen(buff)-2] = 0x00;
			}
			FormatNumberInd(buff2, buff);
		} else {
			FormatNumberWithCentEngl(buff2, pobTran->szTotal);
		}
		if (pobTran->Amt==0) {
			display_at(1, 6, "BILL", CLR_EOL);
			display_at(6, 6, szCurr, CLR_EOL);
		} else {
			display_at(1, 6, "AMT", CLR_EOL);
			display_at(5, 6, szCurr, CLR_EOL);
		}		
		display_at(22-strlen(buff2), 6, buff2,CLR_EOL);
	} else if (pobTran->inOriginalCode == PMT_TRX_CICILAN_FIF) {
		char buff_res[30];
		display_at(1, 3, "NO.KONTRAK", CLR_EOL);
		display_at(22-strlen(pobTran->szInputNumber_1), 4, pobTran->szInputNumber_1, CLR_EOL);

		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE], 20);
		vdTrimSpace(buff);
		display_at(1, 5, "NAMA", CLR_EOL);
		buff[16] = 0x00;
		display_at(22-strlen(buff), 5, buff ,CLR_EOL);

		memset(buff, 0x00, sizeof(buff));
		memset(buff2, 0x00, sizeof(buff2));
		memset(szCurr, 0x00, sizeof(szCurr));
		if (strlen(pobTran->szTotal)==0) {
			memset(pobTran->szTotal, 0x00, sizeof(pobTran->szTotal));
			strncpy(pobTran->szTotal, &pobTran->szF48[63+F48_ADD_SIZE], 12);
			vdUpdateLnTotal(pobTran);
		}
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		if (!strcmp(szCurr, "RP.")) {
			memset(buff, 0x00, sizeof(buff));
			strcpy(buff, pobTran->szTotal);
			if (strlen(buff)>=2) {
				buff[strlen(buff)-2] = 0x00;
			}
			FormatNumberInd(buff2, buff);
		} else {
			FormatNumberWithCentEngl(buff2, pobTran->szTotal);
		}
		if (pobTran->Amt==0) {
			display_at(1, 6, "BILL", CLR_EOL);
			display_at(6, 6, szCurr, CLR_EOL);
		} else {
			display_at(1, 6, "AMT", CLR_EOL);
			display_at(5, 6, szCurr, CLR_EOL);
		}		
		display_at(22-strlen(buff2), 6, buff2,CLR_EOL);
	} else if (pobTran->inOriginalCode == PMT_TRX_CICILAN_TAF) {
		char buff_res[30];
		display_at(1, 2, "NO.KONTRAK", CLR_EOL);
		display_at(22-strlen(pobTran->szInputNumber_1), 3, pobTran->szInputNumber_1, CLR_EOL);

		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE], 20);
		vdTrimSpace(buff);
		display_at(1, 4, "NAMA", CLR_EOL);
		buff[16] = 0x00;
		display_at(22-strlen(buff), 4, buff ,CLR_EOL);

			memset(buff, 0x00, sizeof(buff));
			strncpy(buff, &pobTran->szF48[(1*26)+49+F48_ADD_SIZE], 26);	
			buff[11] = 0x00;
			vdTrimSpace(buff);
			display_at(1, 5, "ANGSURAN", CLR_EOL);
			display_at(22-strlen(buff), 5, buff ,CLR_EOL);
			//sprintf((char *)&printBuf[1], "%-12s: %02d\n", "ANGSURAN", atoi(buff));					
			//retVal = p3300_print(hPrinter, printBuf);		

		memset(buff, 0x00, sizeof(buff));
		memset(buff2, 0x00, sizeof(buff2));
		memset(szCurr, 0x00, sizeof(szCurr));
		if (strlen(pobTran->szTotal)==0) {
			memset(pobTran->szTotal, 0x00, sizeof(pobTran->szTotal));
			strncpy(pobTran->szTotal, &pobTran->szF48[63+F48_ADD_SIZE], 12);
			vdUpdateLnTotal(pobTran);
		}
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		if (!strcmp(szCurr, "RP.")) {
			memset(buff, 0x00, sizeof(buff));
			strcpy(buff, pobTran->szTotal);
			if (strlen(buff)>=2) {
				buff[strlen(buff)-2] = 0x00;
			}
			FormatNumberInd(buff2, buff);
		} else {
			FormatNumberWithCentEngl(buff2, pobTran->szTotal);
		}
		if (pobTran->Amt==0) {
			display_at(1, 6, "BILL", CLR_EOL);
			display_at(6, 6, szCurr, CLR_EOL);
		} else {
			display_at(1, 6, "AMT", CLR_EOL);
			display_at(5, 6, szCurr, CLR_EOL);
		}		
		display_at(22-strlen(buff2), 6, buff2,CLR_EOL);

	} else if (pobTran->inOriginalCode == PMT_TRX_CICILAN_SCB) {
		char buff_res[30];
		display_at(1, 4, "KD.PREFIX+NO.KONTRAK", CLR_EOL);
		display_at(22-strlen(pobTran->szInputNumber_1), 5, pobTran->szInputNumber_1, CLR_EOL);

		if (pobTran->Total>0) {
			char NumBuff[48];
			vdScrollDisplay();
			memset(buff, 0x00, sizeof(buff));
			memset(NumBuff, 0x00, sizeof(NumBuff));
			FormatNumInd(NumBuff, pobTran->Total);
			NumBuff[12] = 0x00;
			sprintf(buff, "AMT RP. %13s", NumBuff);
			display_at(1, 6, buff, CLR_EOL);
		}

	} else if (pobTran->inOriginalCode == PMT_TRX_CICILAN_CITI) {
		char buff_res[30];
		display_at(1, 3, "NO.KONTRAK", CLR_EOL);
		display_at(22-strlen(pobTran->szInputNumber_1), 4, pobTran->szInputNumber_1, CLR_EOL);

		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE], 20);
		vdTrimSpace(buff);
		display_at(1, 5, "NAMA", CLR_EOL);
		buff[16] = 0x00;
		display_at(22-strlen(buff), 5, buff ,CLR_EOL);

		memset(buff, 0x00, sizeof(buff));
		memset(buff2, 0x00, sizeof(buff2));
		memset(szCurr, 0x00, sizeof(szCurr));
		if (strlen(pobTran->szTotal)==0) {
			memset(pobTran->szTotal, 0x00, sizeof(pobTran->szTotal));
			strncpy(pobTran->szTotal, &pobTran->szF48[63+F48_ADD_SIZE], 12);
			vdUpdateLnTotal(pobTran);
		}
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		if (!strcmp(szCurr, "RP.")) {
			memset(buff, 0x00, sizeof(buff));
			strcpy(buff, pobTran->szTotal);
			if (strlen(buff)>=2) {
				buff[strlen(buff)-2] = 0x00;
			}
			FormatNumberInd(buff2, buff);
		} else {
			FormatNumberWithCentEngl(buff2, pobTran->szTotal);
		}
		if (pobTran->Amt==0) {
			display_at(1, 6, "BILL", CLR_EOL);
			display_at(6, 6, szCurr, CLR_EOL);
		} else {
			display_at(1, 6, "AMT", CLR_EOL);
			display_at(5, 6, szCurr, CLR_EOL);
		}		
		display_at(22-strlen(buff2), 6, buff2,CLR_EOL);
	} else if (pobTran->inOriginalCode == PMT_TRX_CICILAN_ADIRA) {
		char buff_res[30];
		display_at(1, 3, "NO.KONTRAK", CLR_EOL);
		display_at(22-strlen(pobTran->szInputNumber_1), 4, pobTran->szInputNumber_1, CLR_EOL);

		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE], 20);
		vdTrimSpace(buff);
		display_at(1, 5, "NAMA", CLR_EOL);
		buff[16] = 0x00;
		display_at(22-strlen(buff), 5, buff ,CLR_EOL);

		memset(buff, 0x00, sizeof(buff));
		memset(buff2, 0x00, sizeof(buff2));
		memset(szCurr, 0x00, sizeof(szCurr));
		if (strlen(pobTran->szTotal)==0) {
			memset(pobTran->szTotal, 0x00, sizeof(pobTran->szTotal));
			strncpy(pobTran->szTotal, &pobTran->szF48[63+F48_ADD_SIZE], 12);
			vdUpdateLnTotal(pobTran);
		}
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		if (!strcmp(szCurr, "RP.")) {
			memset(buff, 0x00, sizeof(buff));
			strcpy(buff, pobTran->szTotal);
			if (strlen(buff)>=2) {
				buff[strlen(buff)-2] = 0x00;
			}
			FormatNumberInd(buff2, buff);
		} else {
			FormatNumberWithCentEngl(buff2, pobTran->szTotal);
		}
		if (pobTran->Amt==0) {
			display_at(1, 6, "BILL", CLR_EOL);
			display_at(6, 6, szCurr, CLR_EOL);
		} else {
			display_at(1, 6, "AMT", CLR_EOL);
			display_at(5, 6, szCurr, CLR_EOL);
		}		
		display_at(22-strlen(buff2), 6, buff2,CLR_EOL);

	} else if (pobTran->inOriginalCode == PMT_TRX_BAYAR_PENDIDIKAN) {
		char buff_res[30];

		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22], 30);
		vdTrimSpace(buff);
		//display_at(1, 2, "INS", CLR_EOL);
		buff[21] = 0x00;
		display_at(22-strlen(buff), 2, buff ,CLR_EOL);
		
		display_at(1, 3, "NO.ID", CLR_EOL);
		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[26+49+F48_ADD_SIZE-26], 11);
		display_at(22-strlen(buff), 3, buff, CLR_EOL);

		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE], 20);
		vdTrimSpace(buff);
		display_at(1, 4, "NAMA", CLR_EOL);
		buff[16] = 0x00;
		display_at(22-strlen(buff), 4, buff ,CLR_EOL);

		display_at(1, 5, "REF TGH", CLR_EOL);
		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[26+49+F48_ADD_SIZE], 11);
		display_at(22-strlen(buff), 5, buff, CLR_EOL);

		memset(buff, 0x00, sizeof(buff));
		memset(buff2, 0x00, sizeof(buff2));
		memset(szCurr, 0x00, sizeof(szCurr));
		if (strlen(pobTran->szTotal)==0) {
			memset(pobTran->szTotal, 0x00, sizeof(pobTran->szTotal));
			strncpy(pobTran->szTotal, &pobTran->szF48[63+F48_ADD_SIZE], 12);
			vdUpdateLnTotal(pobTran);
		}
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		if (!strcmp(szCurr, "RP.")) {
			memset(buff, 0x00, sizeof(buff));
			strcpy(buff, pobTran->szTotal);
			if (strlen(buff)>=2) {
				buff[strlen(buff)-2] = 0x00;
			}
			FormatNumberInd(buff2, buff);
		} else {
			FormatNumberWithCentEngl(buff2, pobTran->szTotal);
		}
		if (pobTran->Amt==0) {
			display_at(1, 6, "BAYAR", CLR_EOL);
			display_at(7, 6, szCurr, CLR_EOL);
		} else {
			display_at(1, 6, "AMT", CLR_EOL);
			display_at(5, 6, szCurr, CLR_EOL);
		}		
		display_at(22-strlen(buff2), 6, buff2,CLR_EOL);
	} else if (pobTran->inOriginalCode == PMT_TRX_BAYAR_ASURANSI) {
		char buff_res[30];

		display_at(1, 3, "KD.INST+NO.POLIS", CLR_EOL);
		display_at(22-strlen(pobTran->szInputNumber_1), 4, pobTran->szInputNumber_1, CLR_EOL);

		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE], 20);
		vdTrimSpace(buff);
		display_at(1, 5, "NAMA", CLR_EOL);
		buff[16] = 0x00;
		display_at(22-strlen(buff), 5, buff ,CLR_EOL);

		memset(buff, 0x00, sizeof(buff));
		memset(buff2, 0x00, sizeof(buff2));
		memset(szCurr, 0x00, sizeof(szCurr));
		if (strlen(pobTran->szTotal)==0) {
			memset(pobTran->szTotal, 0x00, sizeof(pobTran->szTotal));
			strncpy(pobTran->szTotal, &pobTran->szF48[63+F48_ADD_SIZE], 12);
			vdUpdateLnTotal(pobTran);
		}
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		if (!strcmp(szCurr, "RP.")) {
			memset(buff, 0x00, sizeof(buff));
			strcpy(buff, pobTran->szTotal);
			if (strlen(buff)>=2) {
				buff[strlen(buff)-2] = 0x00;
			}
			FormatNumberInd(buff2, buff);
		} else {
			FormatNumberWithCentEngl(buff2, pobTran->szTotal);
		}
		display_at(1, 6, "BILL", CLR_EOL);
		display_at(6, 6, szCurr, CLR_EOL);
		display_at(22-strlen(buff2), 6, buff2,CLR_EOL);
	} else if (pobTran->inOriginalCode == PMT_TRX_BAYAR_TIKET) {
		char buff_res[30];
		
		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22], 30);
		vdTrimSpace(buff);
		display_at(1, 2, "INST", CLR_EOL);
		buff[16] = 0x00;
		display_at(22-strlen(buff), 2, buff ,CLR_EOL);
		
		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[4], 18);  //get from F48 instead of pobTran->szInputNumber_1
		vdTrimSpace(buff);
		display_at(1, 3, "KD.BAYAR", CLR_EOL);
		display_at(22-strlen(buff), 4, buff ,CLR_EOL);

		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE+27+(4*26)], 15);
		vdTrimSpace(buff);
		display_at(1, 5, "KD.BOOKING", CLR_EOL);
		display_at(22-strlen(buff), 5, buff ,CLR_EOL);

		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE], 20);
		vdTrimSpace(buff);
		display_at(1, 6, "NAMA", CLR_EOL);
		buff[16] = 0x00;
		display_at(22-strlen(buff), 6, buff ,CLR_EOL);

		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE+27+(4*26)+15], 2);
		vdTrimSpace(buff);
		display_at(1, 7, "JML.SEAT", CLR_EOL);
		display_at(22-strlen(buff), 7, buff ,CLR_EOL);
		
		if (inDisplayResponseMode==0) {
			pause(lnShowTime/10L);
			set_font(hrf);
			return 1;
		}

		{
			char hrf[20];
			memset(hrf, 0x00, sizeof(hrf));
			get_font(hrf);
			set_font("F:asc8x21i.vft");
			display_at(22-strlen(" NEXT"), 8, " NEXT" ,CLR_EOL);
			vdFlushKeyboardBuffer();
			TimeOut(7000);
			do {
				if (KBHIT()) {
					if (get_char()==0x04) {  //F4
						break;
					}
					TimeOut(7000);
				} else {
					if (TimeOut(0)) break;
					SVC_WAIT(0);
				}
			} while(1);
			set_font(hrf);
		}

		ClearSevenLine();
		display_at(1, 2, "NOMOR PENERBANGAN" ,CLR_EOL);

		memset(buff, 0x00, sizeof(buff));  
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE+27+(4*26)+15+2], 2);  //Carrier
		strncat(buff, &pobTran->szF48[22+F48_ADD_SIZE+27+(4*26)+15+11], 4); //Flight Number
		strncat(buff, "    ", 2);
		strncat(buff, &pobTran->szF48[22+F48_ADD_SIZE+27+(4*26)+15+4], 1);  //Class
		display_at(1, 3, buff, CLR_EOL);

		memset(buff, 0x00, sizeof(buff));  
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE+27+(4*26)+15+5], 3);   //From
		strncat(buff, "-", 1);
		strncat(buff, &pobTran->szF48[22+F48_ADD_SIZE+27+(4*26)+15+8], 3);   //To
		strncat(buff, "  ", 1);
		strncat(buff, &pobTran->szF48[22+F48_ADD_SIZE+27+(4*26)+15+15], 2);  //Date: DD
		strncat(buff, "/", 1);
		strncat(buff, &pobTran->szF48[22+F48_ADD_SIZE+27+(4*26)+15+17], 2);  //Date: MM
		strncat(buff, "  ", 1);
		strncat(buff, &pobTran->szF48[22+F48_ADD_SIZE+27+(4*26)+15+19], 2);  //Time: hh
		strncat(buff, ":", 1);
		strncat(buff, &pobTran->szF48[22+F48_ADD_SIZE+27+(4*26)+15+21], 2);  //Time: mm
		display_at(22-strlen(buff), 4, buff, CLR_EOL);

		memset(buff, 0x00, sizeof(buff));
		memset(buff2, 0x00, sizeof(buff2));
		memset(szCurr, 0x00, sizeof(szCurr));
		if (strlen(pobTran->szTotal)==0) {
			memset(pobTran->szTotal, 0x00, sizeof(pobTran->szTotal));
			strncpy(pobTran->szTotal, &pobTran->szF48[63+F48_ADD_SIZE], 12);
			vdUpdateLnTotal(pobTran);
		}
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		if (!strcmp(szCurr, "RP.")) {
			memset(buff, 0x00, sizeof(buff));
			strcpy(buff, pobTran->szTotal);
			if (strlen(buff)>=2) {
				buff[strlen(buff)-2] = 0x00;
			}
			FormatNumberInd(buff2, buff);
		} else {
			FormatNumberWithCentEngl(buff2, pobTran->szTotal);
		}
		display_at(1, 6, "AMT", CLR_EOL);
		display_at(5, 6, szCurr, CLR_EOL);
		display_at(22-strlen(buff2), 6, buff2,CLR_EOL);
	} else if (pobTran->inOriginalCode == PMT_TRX_BAYAR_PAYID) {
		char buff_res[30];

		display_at(1, 3, "KD.INST+NO.CUST", CLR_EOL);
		display_at(22-strlen(pobTran->szInputNumber_2), 4, pobTran->szInputNumber_2, CLR_EOL);

		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE], 20);
		vdTrimSpace(buff);
		display_at(1, 5, "NAMA", CLR_EOL);
		buff[16] = 0x00;
		display_at(22-strlen(buff), 5, buff ,CLR_EOL);

		memset(buff, 0x00, sizeof(buff));
		memset(buff2, 0x00, sizeof(buff2));
		memset(szCurr, 0x00, sizeof(szCurr));
		if (strlen(pobTran->szTotal)==0) {
			memset(pobTran->szTotal, 0x00, sizeof(pobTran->szTotal));
			strncpy(pobTran->szTotal, &pobTran->szF48[63+F48_ADD_SIZE], 12);
			vdUpdateLnTotal(pobTran);
		}
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		if (!strcmp(szCurr, "RP.")) {
			memset(buff, 0x00, sizeof(buff));
			strcpy(buff, pobTran->szTotal);
			if (strlen(buff)>=2) {
				buff[strlen(buff)-2] = 0x00;
			}
			FormatNumberInd(buff2, buff);
		} else {
			FormatNumberWithCentEngl(buff2, pobTran->szTotal);
		}
		if (pobTran->Amt==0) {
			display_at(1, 6, "BILL", CLR_EOL);
			display_at(6, 6, szCurr, CLR_EOL);
		} else {
			display_at(1, 6, "AMT", CLR_EOL);
			display_at(5, 6, szCurr, CLR_EOL);
		}		
		display_at(22-strlen(buff2), 6, buff2,CLR_EOL);
	} else if (pobTran->inOriginalCode == PMT_TRX_TRANSFER || pobTran->inOriginalCode == PMT_TRX_TRANSFER_REK_LAIN || pobTran->inOriginalCode == PMT_TRX_TRANSFER_BANK_LAIN) {
		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22], 18);
		vdTrimSpace(buff);
		if (strlen(buff)) {
			vdScrollDisplay();
			display_at(1, 7, "NO.REK", CLR_EOL);
			display_at(22-strlen(buff), 7, buff ,CLR_EOL);
		}
		memset(buff, 0x00, sizeof(buff));	
		strncpy(buff, &pobTran->szF48[70], 20);
		vdTrimSpace(buff);
		if (strlen(buff)) {
			vdScrollDisplay();
			display_at(1, 7, "BANK", CLR_EOL);
			buff[16] = 0x00;
			display_at(22-strlen(buff), 7, buff, CLR_EOL);
		} else if (pobTran->inOriginalCode == PMT_TRX_TRANSFER_BANK_LAIN){
			char szInst[4];
			memset(szInst, 0x00, sizeof(szInst));
			strncpy(szInst, pobTran->szInputNumber_2, 3);
			if (atoi(szInst)==13) {
				vdScrollDisplay();
				display_at(1, 7, "BANK", CLR_EOL);
				display_at(22-strlen("PERMATA"), 7, "PERMATA", CLR_EOL);
			}
		}
		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[40], 30);
		vdTrimSpace(buff);
		buff[16] = 0x00;
		if (pobTran->inOriginalCode != PMT_TRX_TRANSFER_BANK_LAIN) vdMaskNameString(buff);
		if (strlen(buff)) {
			vdScrollDisplay();
			display_at(1, 7, "NAMA", CLR_EOL);
			display_at(22-strlen(buff), 7, buff ,CLR_EOL);
		}
		memset(buff, 0x00, sizeof(buff));	
		strncpy(buff, &pobTran->szF48[4], 18);
		vdTrimSpace(buff);
		if (strlen(buff)) {
			vdScrollDisplay();
			display_at(1, 7, "NO.REF", CLR_EOL);
			display_at(22-strlen(buff), 7, buff, CLR_EOL);
		}
		memset(buff, 0x00, sizeof(buff));
		FormatNumInd(buff, pobTran->Total);
		vdScrollDisplay();
		display_at(1, 7, "AMT RP.", CLR_EOL);
		display_at(22-strlen(buff), 7, buff ,CLR_EOL);
		//vdScrollDisplay();
	} else if (pobTran->inOriginalCode == PMT_TRX_PURCHASE){
		inDisplayHostResponse(pobTran);
		vdScrollDisplay();
		vdDisplayMerchantName();
		vdScrollDisplay();
	} else {
		inDisplayHostResponse(pobTran);
		vdScrollDisplay();
		vdScrollDisplay();
		vdScrollDisplay();
	}
	pause(lnShowTime/10L);
	set_font(hrf);
	return 1;	
}


int	RePrintResponse(TRANSACTION_OBJECT *pobTran)
{
	if (!strcmp(pobTran->szRespCode, "00")) {
		DisplayStatus("Printing...!");
		pobTran->inReceiptCopy = 4;  //duplicate
		PrintRcpt(pobTran);
		return 1;
	} else {
		return 0;
	}
}


//initialise the printer
void PrinterInit(void)
{
	int h_font_file;
	open_block_t	parm;
	memset(&parm,0,sizeof(parm));

	parm.rate      = Rt_19200; // Paprika ITP is always set to 19200 baud
	parm.format    = Fmt_A8N1 | Fmt_auto |Fmt_RTS; // Paprika ITP is always set at 8N1
	parm.protocol  = P_char_mode;
    parm.parameter = 0;

	set_opn_blk( hPrinter, &parm);

	SVC_WAIT(200);
	p3300_init(hPrinter, 6);
	SVC_WAIT(100);

	h_font_file = open("F:logo.lgo", O_RDONLY);
	p3300_dnld_graphic_file (hPrinter, h_font_file);
}

int PrintRcpt(TRANSACTION_OBJECT *pobTran)
{
	int inRetval = 0;
	int inUserChoice = 0;

	disable_hot_key();

	inRetval = p3300_status(hPrinter, 3);
	do {
		if (inRetval != 0) {
			if (inRetval == -5 || inRetval == -21) {
				DisplayStatus("Out of Paper!");
			} else {
				DisplayStatus("Printer Error!");
			}
			vdWarnBeep();
			inUserChoice = inMenuChoice("Reprint?", "", " Yes", "No", "");
			if (inUserChoice==2) {
				inRetval = p3300_status(hPrinter, 3);
			} else {
				break;
			}
			//User chance to fix the printer
		}
		if (inRetval==0) {
			inPrintHeader(pobTran);
			inPrintCardDetail(pobTran);
			inPrintTransactionDetail(pobTran);
			inPrintSignature(pobTran);
			inPrintFooter(pobTran);
			inPrintShiftPaper(pobTran);
			inRetval = p3300_status(hPrinter, 3);
		}
	}while(inRetval != 0);

	return 1;
}

void LOG_PRINT_RCPT_HEX(unsigned char* buf, int size)
{
	int i;
	char temp[MSG_BUFF_SIZE*3 + 1];
	char cs[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };	
	int retVal;
	unsigned char printBuf[50];

	memset(temp, 0x00, sizeof(temp));
	if ( size>sizeof(temp)/3 ) size = sizeof(temp)/3;	

	for ( i=0; i<size; i++) {
		temp[i*3] 	= cs[ buf[i]>>4 & 0x0F];
		temp[i*3+1] = cs[ buf[i] & 0x0F];
		temp[i*3+2]	= ' ';
	}

	retVal = p3300_select_font(hPrinter, 0x04, 0); // Set the printer default font to 8x14 at 42
	for ( i=0; i<size/10+1; i++)
	{	
		char tt[31];
		memset(tt, '\0', sizeof(tt));
		memcpy(tt, &(temp[i*30]), 30);
		tt[30] = '\0';
		//LOG_PRINTFF((0x08L, "(%-2d)->(%s)", i, tt));
		memset(printBuf, 0, sizeof(printBuf));
		printBuf[0] = PRINT_NORM;
		sprintf((char *)&printBuf[1], "[%02d] %s\n", i, tt);
		retVal = p3300_print(hPrinter, printBuf);
	}
}

void LOG_PRINT_RCPT(char *buff)
{	
	int retVal;
	unsigned char printBuf[50];

	retVal = p3300_select_font(hPrinter, 0x04, 0); // Set the printer default font to 8x14 at 42
	memset(printBuf, 0, sizeof(printBuf));
	printBuf[0] = PRINT_NORM;
	if (strlen(buff)>48) buff[48] = 0x00;
	sprintf((char *)&printBuf[1], "%s\n", buff);
	retVal = p3300_print(hPrinter, printBuf);
}


int inPrintHeader(TRANSACTION_OBJECT *pobTran)
{
	int retVal;
	unsigned short usOffset;
	unsigned char printBuf[50];
	char buff[128];
	char buff2[128];

	retVal = p3300_select_font(hPrinter, 0x04, 0);
	memset(printBuf, 0, sizeof(printBuf));
	printBuf[0] = PRINT_NORM;
	usOffset = 50;
	//usOffset = 100;
	p3300_print_graphic(hPrinter,0,usOffset);
	sprintf((char *)&printBuf[1], "\n");
	retVal = p3300_print(hPrinter, printBuf);
	
	//printBuf[0] = DBL_HEIGHT;
	printBuf[0] = PRINT_NORM;
	retVal = p3300_select_font(hPrinter, 0x02, 0); // Set the printer default font to 5x8 at 24 column
	//vdFormatText(buff, 32, CENTERED);
	//retVal = p3300_select_font(hPrinter, 0x03, 0); // Set the printer default font to 8x14 at 32 column
	memset(buff, 0x00, sizeof(buff));
	get_env(PRT_HEADER1, buff, sizeof(buff)-1);
	vdTrimSpace(buff);
	if (strlen(buff)) {
		vdFormatText(buff, 24, CENTERED);
		sprintf((char *)&printBuf[1], "%s\n", buff);
		retVal = p3300_print(hPrinter, printBuf);
	}
	printBuf[0] = PRINT_NORM;
	retVal = p3300_select_font(hPrinter, 0x04, 0); // Set the printer default font back to 8x14 at 42
	memset(buff, 0x00, sizeof(buff));
	get_env(PRT_HEADER2, buff, sizeof(buff)-1);
	vdTrimSpace(buff);
	if (strlen(buff)) {
		vdFormatText(buff, 42, CENTERED);
		sprintf((char *)&printBuf[1], "%s\n", buff);
		retVal = p3300_print(hPrinter, printBuf);
	}
	memset(buff, 0x00, sizeof(buff));
	get_env(PRT_HEADER3, buff, sizeof(buff)-1);
	vdTrimSpace(buff);
	if (strlen(buff)) {
		vdFormatText(buff, 42, CENTERED);
		sprintf((char *)&printBuf[1], "%s\n", buff);
		retVal = p3300_print(hPrinter, printBuf);
	}
	memset(buff, 0x00, sizeof(buff));
	get_env(PRT_HEADER4, buff, sizeof(buff)-1);
	vdTrimSpace(buff);
	if (strlen(buff)) {
		vdFormatText(buff, 42, CENTERED);
		sprintf((char *)&printBuf[1], "%s\n", buff);
		retVal = p3300_print(hPrinter, printBuf);
	}
	sprintf((char *)&printBuf[1], "\n");
	retVal = p3300_print(hPrinter, printBuf);

/*
	memset(buff, 0x00, sizeof(buff));
	memset(buff2, 0x00, sizeof(buff2));
	get_env_x(HOST_TERMINAL, 0, buff);
	sprintf(buff2, "(Term. %s/", &buff[strlen(buff)-6]);
	sprintf((char *)&printBuf[1], "Term ID. %33s\n", buff);
	//retVal = p3300_print(hPrinter, printBuf);
	memset(buff, 0x00, sizeof(buff));
	get_env_x(HOST_TERMINAL, 1, buff);
	strcat(buff2, &buff[strlen(buff)-6]);
	strcat(buff2, ")");
	sprintf((char *)&printBuf[1], "Merc ID. %33s\n\n", buff);
	//retVal = p3300_print(hPrinter, printBuf);
	vdFormatText(buff2, 42, CENTERED);
	sprintf((char *)&printBuf[1], "%s\n\n", buff2);
	retVal = p3300_print(hPrinter, printBuf);
*/
	return 1;
}

int inPrintCardDetail(TRANSACTION_OBJECT *pobTran)
{
	int retVal;
	unsigned short usOffset;
	unsigned char printBuf[50];
	char buff[128];
	char buff2[64];
	char buff3[64];

	printBuf[0] = PRINT_NORM;
	memset(buff, 0x00, sizeof(buff));
	memset(buff2, 0x00, sizeof(buff2));
	memset(buff3, 0x00, sizeof(buff3));
	get_env_x(HOST_TERMINAL, 0, buff);
	FormatDate(buff2, pobTran->szDate);
	FormatTime(buff3, pobTran->szTime);
	sprintf((char *)&printBuf[1], "%s %s    TERM# : %11s\n", buff2, buff3, buff);
	retVal = p3300_print(hPrinter, printBuf);

	//printBuf[0] = DBL_WIDTH;
	//printBuf[0] = DBL_HEIGHT;
	memset(buff, 0x00, sizeof(buff));
	FormatDate(buff, pobTran->szExpDate);
    //sprintf((char *)&printBuf[1], "CARD NO: %s exp.%s\n", pobTran->szPAN, buff);
	sprintf((char *)&printBuf[1], "CARD: ");
	retVal = p3300_print(hPrinter, printBuf);

	printBuf[0] = DBL_WIDTH;
	memset(buff, 0x00, sizeof(buff));
	FormatDate(buff, pobTran->szExpDate);
    //sprintf((char *)&printBuf[1], "CARD NO: %s exp.%s\n", pobTran->szPAN, buff);
	sprintf((char *)&printBuf[1], "%s\n", pobTran->szPAN);
	retVal = p3300_print(hPrinter, printBuf);

/*
	printBuf[0] = DBL_WIDTH;
	memset(buff, 0x00, sizeof(buff));
	get_env("J-KARTU", buff, sizeof(buff)-1);
    sprintf((char *)&printBuf[1], "%s\n", buff);
	//retVal = p3300_print(hPrinter, printBuf);
	//printBuf[0] = DBL_WIDTH;
	printBuf[0] = PRINT_NORM;
	memset(buff, 0x00, sizeof(buff));
	FormatDate(buff, pobTran->szExpDate);
    sprintf((char *)&printBuf[1], "%s (Exp. %s)\n", pobTran->szPAN, buff);
	retVal = p3300_select_font(hPrinter, 0x03, 0); // Set the printer default font to 8x14 at 32 column
	retVal = p3300_print(hPrinter, printBuf);
	retVal = p3300_select_font(hPrinter, 0x04, 0); // Set the printer default font back to 8x14 at 42
	printBuf[0] = PRINT_NORM;
    sprintf((char *)&printBuf[1], "%s\n\n", pobTran->szCHolder);
	retVal = p3300_print(hPrinter, printBuf);
*/
	printBuf[0] = PRINT_NORM;
	sprintf((char *)&printBuf[1], "TRACE NO. %06ld       APPR.CODE : %7s\n\n", pobTran->lnInvNum, pobTran->szAuthCode);
	retVal = p3300_print(hPrinter, printBuf);
	return 1;
}

int inPrintTransactionDetail(TRANSACTION_OBJECT *pobTran)
{
	int retVal;
	unsigned short usOffset;
	unsigned char printBuf[128];
	char buff[128];
	char buff2[128];
	char szCurr[5];
	int i=0;

	memset(buff, 0x00, sizeof(buff));
	for (i=0; i<obTranMapCount; i++){
		if (pobTran->inCode == obTranMap[i].inCode) {
			if (pobTran->Status==4) strcpy(buff, "Void ");
			strcat(buff, obTranMap[i].szCode);
		}
	}
	printBuf[0] = DBL_WIDTH;
	//sprintf((char *)&printBuf[1], "%-11s", buff);
	if (pobTran->inCode==PMT_TRX_PURCHASE) {
		sprintf((char *)&printBuf[1], "%-21s\n", "TRANSFER TO MERCHANT");
		retVal = p3300_print(hPrinter, printBuf);
		memset(buff, 0x00, sizeof(buff));
		get_env(PRT_HEADER1, buff, sizeof(buff)-1);
		vdTrimSpace(buff);
		buff[21] = 0x00;
		sprintf((char *)&printBuf[1], "%s\n", buff);
		retVal = p3300_print(hPrinter, printBuf);
	} else if (pobTran->inCode==PMT_TRX_ISI_ULANG) {
		char szInstName[F48_ADD_SIZE+1];
		memset(szInstName, 0x00, sizeof(szInstName));
		strncpy(szInstName, &pobTran->szF48[22], F48_ADD_SIZE);
		vdTrimSpace(szInstName);
		sprintf((char *)&printBuf[1], "%-21s\n", "ISI ULANG");
		retVal = p3300_print(hPrinter, printBuf);
		sprintf((char *)&printBuf[1], "%s\n", szInstName);
	    if (strlen(szInstName)>20) printBuf[0] = PRINT_NORM;	
		if (strlen(szInstName)) retVal = p3300_print(hPrinter, printBuf);	
	} else if (pobTran->inCode==PMT_TRX_REGISTRASI) {
		sprintf((char *)&printBuf[1], "%-21s\n", buff);
		retVal = p3300_print(hPrinter, printBuf);
		sprintf((char *)&printBuf[1], "PermataMobile\n");
		retVal = p3300_print(hPrinter, printBuf);		
	} else if (pobTran->inCode==PMT_TRX_BAYAR_TELPON) {
		char szInstName[F48_ADD_SIZE+1];
		memset(szInstName, 0x00, sizeof(szInstName));
		strncpy(szInstName, &pobTran->szF48[22], F48_ADD_SIZE);
		vdTrimSpace(szInstName);
		sprintf((char *)&printBuf[1], "%-21s\n", "PEMBAYARAN");
		retVal = p3300_print(hPrinter, printBuf);
		//sprintf((char *)&printBuf[1], "TELEPON/HP\n");
		//retVal = p3300_print(hPrinter, printBuf);		
		sprintf((char *)&printBuf[1], "%s\n", szInstName);
	    if (strlen(szInstName)>20) printBuf[0] = PRINT_NORM;	
		if (strlen(szInstName)) retVal = p3300_print(hPrinter, printBuf);	
	} else if (pobTran->inCode==PMT_TRX_BAYAR_PLN) {
		char szInstName[F48_ADD_SIZE+1];
		memset(szInstName, 0x00, sizeof(szInstName));
		strncpy(szInstName, &pobTran->szF48[22], F48_ADD_SIZE);
		vdTrimSpace(szInstName);
		sprintf((char *)&printBuf[1], "%-21s\n", "PEMBAYARAN");
		retVal = p3300_print(hPrinter, printBuf);
		//sprintf((char *)&printBuf[1], "P L N\n");
		//retVal = p3300_print(hPrinter, printBuf);		
		sprintf((char *)&printBuf[1], "%s\n", szInstName);
	    if (strlen(szInstName)>20) printBuf[0] = PRINT_NORM;	
		if (strlen(szInstName)) retVal = p3300_print(hPrinter, printBuf);	
	} else if (pobTran->inCode==PMT_TRX_BAYAR_PALYJA) {
		char szInstName[F48_ADD_SIZE+1];
		memset(szInstName, 0x00, sizeof(szInstName));
		strncpy(szInstName, &pobTran->szF48[22], F48_ADD_SIZE);
		vdTrimSpace(szInstName);
		sprintf((char *)&printBuf[1], "%-21s\n", "PEMBAYARAN");
		retVal = p3300_print(hPrinter, printBuf);
		//sprintf((char *)&printBuf[1], "PALYJA\n");
		//retVal = p3300_print(hPrinter, printBuf);
		sprintf((char *)&printBuf[1], "%s\n", szInstName);
	    if (strlen(szInstName)>20) printBuf[0] = PRINT_NORM;	
		if (strlen(szInstName)) retVal = p3300_print(hPrinter, printBuf);	
	} else if (pobTran->inCode==PMT_TRX_BAYAR_PAM) {
		char szInstName[F48_ADD_SIZE+1];
		memset(szInstName, 0x00, sizeof(szInstName));
		strncpy(szInstName, &pobTran->szF48[22], F48_ADD_SIZE);
		vdTrimSpace(szInstName);
		sprintf((char *)&printBuf[1], "%-21s\n", "PEMBAYARAN");
		retVal = p3300_print(hPrinter, printBuf);
		//sprintf((char *)&printBuf[1], "PAM BINTARO JAYA\n");
		//retVal = p3300_print(hPrinter, printBuf);		
		sprintf((char *)&printBuf[1], "%s\n", szInstName);
	    if (strlen(szInstName)>20) printBuf[0] = PRINT_NORM;	
		if (strlen(szInstName)) retVal = p3300_print(hPrinter, printBuf);	
	} else if (pobTran->inCode==PMT_TRX_BAYAR_CDTCARD) {
		char szInstName[F48_ADD_SIZE+1];
		memset(szInstName, 0x00, sizeof(szInstName));
		strncpy(szInstName, &pobTran->szF48[22], F48_ADD_SIZE);
		vdTrimSpace(szInstName);
		sprintf((char *)&printBuf[1], "%-21s\n", "PEMBAYARAN");
		retVal = p3300_print(hPrinter, printBuf);
		//sprintf((char *)&printBuf[1], "KARTU KREDIT\n");
		//retVal = p3300_print(hPrinter, printBuf);		
		sprintf((char *)&printBuf[1], "%s\n", szInstName);
		if (strlen(szInstName)>20) printBuf[0] = PRINT_NORM;	
		if (strlen(szInstName)) retVal = p3300_print(hPrinter, printBuf);			
	} else if (pobTran->inCode==PMT_TRX_CICILAN_ACC) {
		char szInstName[F48_ADD_SIZE+1];
		memset(szInstName, 0x00, sizeof(szInstName));
		strncpy(szInstName, &pobTran->szF48[22], F48_ADD_SIZE);
		vdTrimSpace(szInstName);

		sprintf((char *)&printBuf[1], "%-21s\n", "PEMBAYARAN");
		retVal = p3300_print(hPrinter, printBuf);
		//sprintf((char *)&printBuf[1], "ASTRA CREDIT COMPANY\n");
		//retVal = p3300_print(hPrinter, printBuf);		
		sprintf((char *)&printBuf[1], "%s\n", szInstName);
		if (strlen(szInstName)>20) printBuf[0] = PRINT_NORM;	
		if (strlen(szInstName)) retVal = p3300_print(hPrinter, printBuf);			
	} else if (pobTran->inCode==PMT_TRX_CICILAN_FIF) {
		char szInstName[F48_ADD_SIZE+1];
		memset(szInstName, 0x00, sizeof(szInstName));
		strncpy(szInstName, &pobTran->szF48[22], F48_ADD_SIZE);
		vdTrimSpace(szInstName);
		sprintf((char *)&printBuf[1], "%-21s\n", "PEMBAYARAN");
		retVal = p3300_print(hPrinter, printBuf);
		//sprintf((char *)&printBuf[1], "F I F\n");
		//retVal = p3300_print(hPrinter, printBuf);		
		sprintf((char *)&printBuf[1], "%s\n", szInstName);
		if (strlen(szInstName)>20) printBuf[0] = PRINT_NORM;	
		if (strlen(szInstName)) retVal = p3300_print(hPrinter, printBuf);			
	} else if (pobTran->inCode==PMT_TRX_CICILAN_TAF) {
		char szInstName[F48_ADD_SIZE+1];
		memset(szInstName, 0x00, sizeof(szInstName));
		strncpy(szInstName, &pobTran->szF48[22], F48_ADD_SIZE);
		vdTrimSpace(szInstName);
		sprintf((char *)&printBuf[1], "%-21s\n", "PEMBAYARAN");
		retVal = p3300_print(hPrinter, printBuf);
		//sprintf((char *)&printBuf[1], "F I F\n");
		//retVal = p3300_print(hPrinter, printBuf);		
		sprintf((char *)&printBuf[1], "%s\n", szInstName);
		if (strlen(szInstName)>20) printBuf[0] = PRINT_NORM;	
		if (strlen(szInstName)) retVal = p3300_print(hPrinter, printBuf);			
	} else if (pobTran->inCode==PMT_TRX_CICILAN_SCB) {
		char szInstName[F48_ADD_SIZE+1];
		memset(szInstName, 0x00, sizeof(szInstName));
		strncpy(szInstName, &pobTran->szF48[22], F48_ADD_SIZE);
		vdTrimSpace(szInstName);
		sprintf((char *)&printBuf[1], "%-21s\n", "PEMBAYARAN");
		retVal = p3300_print(hPrinter, printBuf);
		//sprintf((char *)&printBuf[1], "F I F\n");
		//retVal = p3300_print(hPrinter, printBuf);		
		sprintf((char *)&printBuf[1], "%s\n", szInstName);
		if (strlen(szInstName)>20) printBuf[0] = PRINT_NORM;	
		if (strlen(szInstName)) retVal = p3300_print(hPrinter, printBuf);			
	} else if (pobTran->inCode==PMT_TRX_CICILAN_CITI) {
		char szInstName[F48_ADD_SIZE+1];
		memset(szInstName, 0x00, sizeof(szInstName));
		strncpy(szInstName, &pobTran->szF48[22], F48_ADD_SIZE);
		vdTrimSpace(szInstName);
		sprintf((char *)&printBuf[1], "%-21s\n", "PEMBAYARAN");
		retVal = p3300_print(hPrinter, printBuf);
		//sprintf((char *)&printBuf[1], "F I F\n");
		//retVal = p3300_print(hPrinter, printBuf);		
		sprintf((char *)&printBuf[1], "%s\n", szInstName);
		if (strlen(szInstName)>20) printBuf[0] = PRINT_NORM;	
		if (strlen(szInstName)) retVal = p3300_print(hPrinter, printBuf);			
	} else if (pobTran->inCode==PMT_TRX_CICILAN_ADIRA) {
		char szInstName[F48_ADD_SIZE+1];
		memset(szInstName, 0x00, sizeof(szInstName));
		strncpy(szInstName, &pobTran->szF48[22], F48_ADD_SIZE);
		vdTrimSpace(szInstName);
		sprintf((char *)&printBuf[1], "%-21s\n", "PEMBAYARAN");
		retVal = p3300_print(hPrinter, printBuf);
		//sprintf((char *)&printBuf[1], "F I F\n");
		//retVal = p3300_print(hPrinter, printBuf);		
		sprintf((char *)&printBuf[1], "%s\n", szInstName);
		if (strlen(szInstName)>20) printBuf[0] = PRINT_NORM;	
		if (strlen(szInstName)) retVal = p3300_print(hPrinter, printBuf);			
	} else if (pobTran->inCode==PMT_TRX_BAYAR_PENDIDIKAN) {
		char szInst[4];
		char szInstName[F48_ADD_SIZE+1];
		memset(szInst, 0x00, sizeof(szInst));
		memset(szInstName, 0x00, sizeof(szInstName));
		strncpy(szInst, pobTran->szInputNumber_1, 3);
		strncpy(szInstName, &pobTran->szF48[22], F48_ADD_SIZE);
		vdTrimSpace(szInstName);
		sprintf((char *)&printBuf[1], "%-21s\n", "PEMBAYARAN");
		retVal = p3300_print(hPrinter, printBuf);
		//sprintf((char *)&printBuf[1], "PENDIDIKAN\n");
		//retVal = p3300_print(hPrinter, printBuf);	
		//sprintf((char *)&printBuf[1], "(%s)\n", szInst);
		sprintf((char *)&printBuf[1], "%s\n", szInstName);
		if (strlen(szInstName)>20) printBuf[0] = PRINT_NORM;	
		if (strlen(szInstName)) retVal = p3300_print(hPrinter, printBuf);			
	} else if (pobTran->inCode==PMT_TRX_BAYAR_ASURANSI) {
		char szInstName[F48_ADD_SIZE+1];
		memset(szInstName, 0x00, sizeof(szInstName));
		strncpy(szInstName, &pobTran->szF48[22], F48_ADD_SIZE);
		vdTrimSpace(szInstName);
		sprintf((char *)&printBuf[1], "%-21s\n", "PEMBAYARAN");
		retVal = p3300_print(hPrinter, printBuf);
		//sprintf((char *)&printBuf[1], "ASURANSI\n");
		//retVal = p3300_print(hPrinter, printBuf);		
		sprintf((char *)&printBuf[1], "%s\n", szInstName);
		if (strlen(szInstName)>20) printBuf[0] = PRINT_NORM;	
		if (strlen(szInstName)) retVal = p3300_print(hPrinter, printBuf);			
	} else if (pobTran->inCode==PMT_TRX_BAYAR_TIKET) {
		char szInstName[F48_ADD_SIZE+1];
		memset(szInstName, 0x00, sizeof(szInstName));
		strncpy(szInstName, &pobTran->szF48[22], F48_ADD_SIZE);
		vdTrimSpace(szInstName);
		sprintf((char *)&printBuf[1], "%-21s\n", "PEMBAYARAN");
		retVal = p3300_print(hPrinter, printBuf);
		sprintf((char *)&printBuf[1], "%s\n", szInstName);
		if (strlen(szInstName)>20) printBuf[0] = PRINT_NORM;	
		if (strlen(szInstName)) retVal = p3300_print(hPrinter, printBuf);			
	} else if (pobTran->inCode==PMT_TRX_BAYAR_PAYID) {
		char szInst[4];
		char szInstName[F48_ADD_SIZE+1];
		memset(szInst, 0x00, sizeof(szInst));
		memset(szInstName, 0x00, sizeof(szInstName));
		strncpy(szInst, pobTran->szInputNumber_1, 3);
		strncpy(szInstName, &pobTran->szF48[22], F48_ADD_SIZE);
		vdTrimSpace(szInstName);
		sprintf((char *)&printBuf[1], "%-21s\n", "PEMBAYARAN");
		retVal = p3300_print(hPrinter, printBuf);	
		sprintf((char *)&printBuf[1], "%s\n", szInstName);
		if (strlen(szInstName)>20) printBuf[0] = PRINT_NORM;	
		if (strlen(szInstName)) retVal = p3300_print(hPrinter, printBuf);	
	} else if (pobTran->inCode==PMT_TRX_TRANSFER) {
		sprintf((char *)&printBuf[1], "%-21s\n", "TRANSFER REKENING");
		retVal = p3300_print(hPrinter, printBuf);
		sprintf((char *)&printBuf[1], " \n");
		retVal = p3300_print(hPrinter, printBuf);		
	} else if (pobTran->inCode==PMT_TRX_TRANSFER_REK_LAIN) {
		sprintf((char *)&printBuf[1], "%-21s\n", buff);
		retVal = p3300_print(hPrinter, printBuf);
		sprintf((char *)&printBuf[1], " \n");
		retVal = p3300_print(hPrinter, printBuf);		
	} else if (pobTran->inCode==PMT_TRX_TRANSFER_BANK_LAIN) {
		sprintf((char *)&printBuf[1], "%-21s\n", buff);
		retVal = p3300_print(hPrinter, printBuf);
		sprintf((char *)&printBuf[1], " \n");
		retVal = p3300_print(hPrinter, printBuf);		
	} else {
		sprintf((char *)&printBuf[1], "%-21s\n", buff);
		retVal = p3300_print(hPrinter, printBuf);
	}

////////////////////////
///Here for custom print
////////////////////////
	printBuf[0] = PRINT_NORM;
	if (pobTran->inCode==PMT_TRX_PURCHASE) {
		memset(buff, 0x00, sizeof(buff));
		FormatNumInd(buff, pobTran->Total);
		sprintf((char *)&printBuf[1], "%-12s: RP. %20s\n", "TOTAL", buff);		
		retVal = p3300_print(hPrinter, printBuf);
		
		{
			memset(buff, 0x00, sizeof(buff));
			vdGetTrxFee(buff, pobTran);
			if (strlen(buff)) {
				sprintf((char *)&printBuf[1], "%-12s: RP. %20s\n", "BIAYA", buff);		
				retVal = p3300_print(hPrinter, printBuf);
				memset(buff, 0x00, sizeof(buff));
				strcpy(buff, "ATAU BIAYA SESUAI KETENTUAN BANK ANDA");
				sprintf((char *)&printBuf[1], "%s\n", buff);		
				retVal = p3300_print(hPrinter, printBuf);
			}
		}
		sprintf((char *)&printBuf[1], " \n");		
		retVal = p3300_print(hPrinter, printBuf);
	} else if (pobTran->inCode==PMT_TRX_ISI_ULANG) {
		sprintf((char *)&printBuf[1], "%-12s: %-20s\n", "NO.HP", pobTran->szInputNumber_1);		
		retVal = p3300_print(hPrinter, printBuf);
		sprintf((char *)&printBuf[1], "%-12s: %-20s\n", "VOUCHER SN", pobTran->szVoucherSN);		
		retVal = p3300_print(hPrinter, printBuf);
		memset(buff, 0x00, sizeof(buff));
		FormatNumInd(buff, pobTran->lnVoucherAmt);
		sprintf((char *)&printBuf[1], "%-12s: RP. %20s\n\n", "PEMBAYARAN", buff);		
		retVal = p3300_print(hPrinter, printBuf);
	} else if (pobTran->inCode==PMT_TRX_REGISTRASI) {
		sprintf((char *)&printBuf[1], "%-12s: %-20s\n\n", "NO.HP", pobTran->szInputNumber_1);		
		retVal = p3300_print(hPrinter, printBuf);
	} else if (pobTran->inCode==PMT_TRX_INFO_SALDO) {
		memset(szCurr, 0x00, sizeof(szCurr));
		memset(buff, 0x00, sizeof(buff));
		FormatNumberWithCentInd(buff, &pobTran->szF54[6]);
		vdGetCurrency(szCurr, &pobTran->szF54[2]);
		sprintf((char *)&printBuf[1], "%-12s: %s %s\n\n", "SALDO", szCurr, buff);		
		retVal = p3300_print(hPrinter, printBuf);
	} else if (pobTran->inCode==PMT_TRX_MINI_STATEMENT) {
		char chSign=' ';
		sprintf((char *)&printBuf[1], "%-9s%-17s   %s\n\n", "TGL", "KETERANGAN", "NILAI (IDR)");		
		retVal = p3300_print(hPrinter, printBuf);		
		memset(buff, 0x00, sizeof(buff));
		memset(szCurr, 0x00, sizeof(szCurr));
		vdGetCurrency(szCurr, &pobTran->szF54[2]);
		for (i=0; (22+(i+1)*31)<=strlen(pobTran->szF48); i++) {
		//for (i=0; i<8; i++) {
			memset(buff, 0x00, sizeof(buff));
			strncpy(buff, &pobTran->szF48[(i*31)+22], 31);
			memset(buff2, 0x00, sizeof(buff2));
			FormatNumberWithCentEngl(buff2, &buff[19]);
			if (strlen(buff2)==4 && atoi(buff2)==0 && atoi(&buff2[2])==0) continue;
			if (!strcmp(szCurr, "RP.")) {
				FormatNumberWithCentInd(buff2, &buff[19]);
				if (strlen(buff2)>=3) buff2[strlen(buff2)-3] = 0x00;
			}
			chSign = buff[18];
			buff[18] = 0x00;
			strncpy((char *)&printBuf[1], &buff[2], 4);
			strncpy((char *)&printBuf[5], "           ", 5); 
			sprintf((char *)&printBuf[10], "%s   %17s%c\n", &buff[6], buff2, chSign); 
			retVal = p3300_print(hPrinter, printBuf);		
		}
		memset(buff, 0x00, sizeof(buff));
		memset(szCurr, 0x00, sizeof(szCurr));
		FormatNumberWithCentInd(buff, &pobTran->szF54[6]);
		vdGetCurrency(szCurr, &pobTran->szF54[2]);
		sprintf((char *)&printBuf[1], "\n%-12s: %s %24s\n\n", "SALDO", szCurr, buff);		
		retVal = p3300_print(hPrinter, printBuf);		
	} else if (pobTran->inOriginalCode == PMT_TRX_BAYAR_TELPON) {
		sprintf((char *)&printBuf[1], "%-12s: %s\n", "TELP/HP", pobTran->szInputNumber_1);		
		retVal = p3300_print(hPrinter, printBuf);
		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE], 20);
		vdTrimSpace(buff);
		sprintf((char *)&printBuf[1], "%-12s: %s\n", "NAMA", buff);		
		retVal = p3300_print(hPrinter, printBuf);
/*
		for (i=1; (F48_ADD_SIZE+49+(i+1)*26)<=strlen(pobTran->szF48); i++) {
			memset(buff, 0x00, sizeof(buff));
			strncpy(buff, &pobTran->szF48[(i*26)+49+F48_ADD_SIZE], 26);
			memset(buff2, 0x00, sizeof(buff2));
			memset(szCurr, 0x00, sizeof(szCurr));
			vdGetCurrency(szCurr, &buff[11]);
			FormatNumberWithCentEngl(buff2, &buff[14]);
			if (strlen(buff2)==4 && atoi(buff2)==0 && atoi(&buff2[2])==0) continue;
			if (!strcmp(szCurr, "RP.")) {
				FormatNumberWithCentInd(buff2, &buff[14]);
				if (strlen(buff2)>=3) buff2[strlen(buff2)-3] = 0x00;
			}
			buff[11] = 0x00;
			buff[3] = 0x00;
			vdGetMonthStr(buff, atoi(&buff[1]));
			sprintf((char *)&printBuf[1], "%-12s: %s %20s\n", buff, szCurr, buff2);					
			retVal = p3300_print(hPrinter, printBuf);		
		}
*/
		memset(buff, 0x00, sizeof(buff));
		memset(szCurr, 0x00, sizeof(szCurr));
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		FormatNumberWithCentEngl(buff, pobTran->szTotal);
		if (!strcmp(szCurr, "RP.")) {
			FormatNumberWithCentInd(buff, pobTran->szTotal);
			if (strlen(buff)>=3) buff[strlen(buff)-3] = 0x00;
		}
		sprintf((char *)&printBuf[1], "%-12s: %s %20s\n\n", "TOTAL", szCurr, buff);		
		retVal = p3300_print(hPrinter, printBuf);
	} else if (pobTran->inOriginalCode == PMT_TRX_BAYAR_PLN) {
		sprintf((char *)&printBuf[1], "%-15s: %s\n", "ID PEL", pobTran->szInputNumber_1);		
		retVal = p3300_print(hPrinter, printBuf);
		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE], 20);
		vdTrimSpace(buff);
		sprintf((char *)&printBuf[1], "%-15s: %s\n", "NAMA", buff);		
		retVal = p3300_print(hPrinter, printBuf);
/*
		for (i=1; (49+(i+1)*26)<=strlen(pobTran->szF48); i++) {
			memset(buff, 0x00, sizeof(buff));
			strncpy(buff, &pobTran->szF48[(i*26)+49], 26);
			memset(buff2, 0x00, sizeof(buff2));
			memset(szCurr, 0x00, sizeof(szCurr));
			vdGetCurrency(szCurr, &buff[11]);
			FormatNumberWithCent(buff2, &buff[14]);
			if (strlen(buff2)==4 && atoi(buff2)==0 && atoi(&buff2[2])==0) continue;
			buff[11] = 0x00;
			sprintf((char *)&printBuf[1], "%-12s: %s %20s\n", buff, szCurr, buff2);					
			retVal = p3300_print(hPrinter, printBuf);		
		}
*/
			memset(buff, 0x00, sizeof(buff));
			//strncpy(buff, &pobTran->szF48[(1*26)+49+F48_ADD_SIZE], 26);
			//buff[5] = 0x00;
			//memmove(&buff[3], &buff[2], 2);
			//buff[2] = '/';
			strncpy(buff, &pobTran->szF48[49+F48_ADD_SIZE+(4*26)+80], 20);
			vdTrimSpace(buff);
			for(i=0; i<strlen(buff); i++) {
				if (isspace(buff[i])) buff[i] = ',';
			}
			sprintf((char *)&printBuf[1], "%-15s: %s\n", "BL/TH", buff);					
			retVal = p3300_print(hPrinter, printBuf);		

			memset(buff, 0x00, sizeof(buff));
			strncpy(buff, &pobTran->szF48[49+F48_ADD_SIZE+(4*26)+32], 8);
			strcat(buff, " - ");
			strncat(buff, &pobTran->szF48[49+F48_ADD_SIZE+(4*26)+40], 8);
			sprintf((char *)&printBuf[1], "%-15s: %s\n", "LWBP TERAKHIR", buff);					
			retVal = p3300_print(hPrinter, printBuf);		

		memset(buff, 0x00, sizeof(buff));
		memset(szCurr, 0x00, sizeof(szCurr));
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		FormatNumberWithCentEngl(buff, pobTran->szTotal);
		if (!strcmp(szCurr, "RP.")) {
			FormatNumberWithCentInd(buff, pobTran->szTotal);
			if (strlen(buff)>=3) buff[strlen(buff)-3] = 0x00;
		}
		sprintf((char *)&printBuf[1], "%-15s: %s %20s\n", "JUMLAH TAGIHAN", szCurr, buff);		
		retVal = p3300_print(hPrinter, printBuf);

			memset(buff, 0x00, sizeof(buff));
			strncpy(buff, &pobTran->szF48[49+F48_ADD_SIZE+(4*26)+13], 19);
			vdTrimSpace(buff);
			sprintf((char *)&printBuf[1], "%-15s: %s\n\n", "MLPO REF", buff);					
			retVal = p3300_print(hPrinter, printBuf);		

	} else if (pobTran->inOriginalCode == PMT_TRX_BAYAR_PALYJA) {
		sprintf((char *)&printBuf[1], "%-12s: %s\n", "NO.PALYJA", pobTran->szInputNumber_1);		
		retVal = p3300_print(hPrinter, printBuf);
		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE], 20);
		vdTrimSpace(buff);
		sprintf((char *)&printBuf[1], "%-12s: %s\n", "NAMA", buff);		
		retVal = p3300_print(hPrinter, printBuf);

		for (i=1; (F48_ADD_SIZE+49+(i+1)*26)<=strlen(pobTran->szF48); i++) {
			memset(buff, 0x00, sizeof(buff));
			strncpy(buff, &pobTran->szF48[(i*26)+49+F48_ADD_SIZE], 26);
			memset(buff2, 0x00, sizeof(buff2));
			memset(szCurr, 0x00, sizeof(szCurr));
			vdGetCurrency(szCurr, &buff[11]);
			FormatNumberWithCentEngl(buff2, &buff[14]);
			if (strlen(buff2)==4 && atoi(buff2)==0 && atoi(&buff2[2])==0) continue;
			if (!strcmp(szCurr, "RP.")) {
				FormatNumberWithCentInd(buff2, &buff[14]);
				if (strlen(buff2)>=3) buff2[strlen(buff2)-3] = 0x00;
			}
			buff[11] = 0x00;
			sprintf((char *)&printBuf[1], "%-12s: %s %20s\n", buff, szCurr, buff2);					
			retVal = p3300_print(hPrinter, printBuf);		
		}

		memset(buff, 0x00, sizeof(buff));
		memset(szCurr, 0x00, sizeof(szCurr));
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		FormatNumberWithCentEngl(buff, pobTran->szTotal);
		if (!strcmp(szCurr, "RP.")) {
			FormatNumberWithCentInd(buff, pobTran->szTotal);
			if (strlen(buff)>=3) buff[strlen(buff)-3] = 0x00;
		}
		sprintf((char *)&printBuf[1], "%-12s: %s %20s\n\n", "TOTAL", szCurr, buff);		
		retVal = p3300_print(hPrinter, printBuf);
	} else if (pobTran->inOriginalCode == PMT_TRX_BAYAR_PAM) {
		sprintf((char *)&printBuf[1], "%-12s: %s\n", "NO.PAM", pobTran->szInputNumber_1);		
		retVal = p3300_print(hPrinter, printBuf);
		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE], 20);
		vdTrimSpace(buff);
		sprintf((char *)&printBuf[1], "%-12s: %s\n", "NAMA", buff);		
		retVal = p3300_print(hPrinter, printBuf);

		for (i=1; (F48_ADD_SIZE+49+(i+1)*26)<=strlen(pobTran->szF48); i++) {
			memset(buff, 0x00, sizeof(buff));
			strncpy(buff, &pobTran->szF48[(i*26)+49+F48_ADD_SIZE], 26);
			memset(buff2, 0x00, sizeof(buff2));
			memset(szCurr, 0x00, sizeof(szCurr));
			vdGetCurrency(szCurr, &buff[11]);
			FormatNumberWithCentEngl(buff2, &buff[14]);
			if (strlen(buff2)==4 && atoi(buff2)==0 && atoi(&buff2[2])==0) continue;
			if (!strcmp(szCurr, "RP.")) {
				FormatNumberWithCentInd(buff2, &buff[14]);
				if (strlen(buff2)>=3) buff2[strlen(buff2)-3] = 0x00;
			}
			buff[11] = 0x00;
			sprintf((char *)&printBuf[1], "%-12s: %s %20s\n", buff, szCurr, buff2);					
			retVal = p3300_print(hPrinter, printBuf);		
		}

		memset(buff, 0x00, sizeof(buff));
		memset(szCurr, 0x00, sizeof(szCurr));
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		FormatNumberWithCentEngl(buff, pobTran->szTotal);
		if (!strcmp(szCurr, "RP.")) {
			FormatNumberWithCentInd(buff, pobTran->szTotal);
			if (strlen(buff)>=3) buff[strlen(buff)-3] = 0x00;
		}
		sprintf((char *)&printBuf[1], "%-12s: %s %20s\n\n", "TOTAL", szCurr, buff);		
		retVal = p3300_print(hPrinter, printBuf);
	} else if (pobTran->inOriginalCode == PMT_TRX_CICILAN_ACC) {
		sprintf((char *)&printBuf[1], "%-12s: %s\n", "NO.KONTRAK", pobTran->szInputNumber_1);		
		retVal = p3300_print(hPrinter, printBuf);
		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE], 20);
		vdTrimSpace(buff);
		sprintf((char *)&printBuf[1], "%-12s: %s\n", "NAMA", buff);		
		retVal = p3300_print(hPrinter, printBuf);

		for (i=1; (F48_ADD_SIZE+49+(i+1)*26)<=strlen(pobTran->szF48); i++) {
			memset(buff, 0x00, sizeof(buff));
			strncpy(buff, &pobTran->szF48[(i*26)+49+F48_ADD_SIZE], 26);
			memset(buff2, 0x00, sizeof(buff2));
			memset(szCurr, 0x00, sizeof(szCurr));
			vdGetCurrency(szCurr, &buff[11]);
			FormatNumberWithCentEngl(buff2, &buff[14]);
			if (strlen(buff2)==4 && atoi(buff2)==0 && atoi(&buff2[2])==0) continue;
			if (!strcmp(szCurr, "RP.")) {
				FormatNumberWithCentInd(buff2, &buff[14]);
				if (strlen(buff2)>=3) buff2[strlen(buff2)-3] = 0x00;
			}
			buff[11] = 0x00;
			sprintf((char *)&printBuf[1], "%-12s: %s %20s\n", buff, szCurr, buff2);					
			retVal = p3300_print(hPrinter, printBuf);		
		}

		memset(buff , 0x00, sizeof(buff ));
		memset(buff2, 0x00, sizeof(buff2));
		memset(szCurr, 0x00, sizeof(szCurr));
		strncpy(buff, &pobTran->szF48[63+F48_ADD_SIZE], 12);
		FormatNumberWithCentEngl(buff2, buff);
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		if (!strcmp(szCurr, "RP.")) {
			FormatNumberWithCentInd(buff2, buff);
			if (strlen(buff2)>=3) buff2[strlen(buff2)-3] = 0x00;
		}
		sprintf((char *)&printBuf[1], "%-12s: %s %20s\n", "TAGIHAN", szCurr, buff2);		
		retVal = p3300_print(hPrinter, printBuf);

		memset(buff, 0x00, sizeof(buff));
		memset(szCurr, 0x00, sizeof(szCurr));
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		FormatNumberWithCentEngl(buff, pobTran->szTotal);
		if (!strcmp(szCurr, "RP.")) {
			FormatNumberWithCentInd(buff, pobTran->szTotal);
			if (strlen(buff)>=3) buff[strlen(buff)-3] = 0x00;
		}
		sprintf((char *)&printBuf[1], "%-12s: %s %20s\n\n", "BAYAR", szCurr, buff);		
		retVal = p3300_print(hPrinter, printBuf);
	} else if (pobTran->inOriginalCode == PMT_TRX_CICILAN_FIF) {
		sprintf((char *)&printBuf[1], "%-12s: %s\n", "NO.KONTRAK", pobTran->szInputNumber_1);		
		retVal = p3300_print(hPrinter, printBuf);
		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE], 20);
		vdTrimSpace(buff);
		sprintf((char *)&printBuf[1], "%-12s: %s\n", "NAMA", buff);		
		retVal = p3300_print(hPrinter, printBuf);
		
			memset(buff, 0x00, sizeof(buff));
			strncpy(buff, &pobTran->szF48[(1*26)+49+F48_ADD_SIZE], 26);	
			buff[4] = 0x00;
			sprintf((char *)&printBuf[1], "%-12s: %02d\n", "ANGSURAN", atoi(buff));					
			retVal = p3300_print(hPrinter, printBuf);		

		memset(buff , 0x00, sizeof(buff ));
		memset(buff2, 0x00, sizeof(buff2));
		memset(szCurr, 0x00, sizeof(szCurr));
		strncpy(buff, &pobTran->szF48[63+F48_ADD_SIZE], 12);
		FormatNumberWithCentEngl(buff2, buff);
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		if (!strcmp(szCurr, "RP.")) {
			FormatNumberWithCentInd(buff2, buff);
			if (strlen(buff2)>=3) buff2[strlen(buff2)-3] = 0x00;
		}
		sprintf((char *)&printBuf[1], "%-12s: %s %20s\n", "TAGIHAN", szCurr, buff2);		
		retVal = p3300_print(hPrinter, printBuf);

		memset(buff, 0x00, sizeof(buff));
		memset(szCurr, 0x00, sizeof(szCurr));
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		FormatNumberWithCentEngl(buff, pobTran->szTotal);
		if (!strcmp(szCurr, "RP.")) {
			FormatNumberWithCentInd(buff, pobTran->szTotal);
			if (strlen(buff)>=3) buff[strlen(buff)-3] = 0x00;
		}
		sprintf((char *)&printBuf[1], "%-12s: %s %20s\n\n", "BAYAR", szCurr, buff);		
		retVal = p3300_print(hPrinter, printBuf);
	} else if (pobTran->inOriginalCode == PMT_TRX_CICILAN_TAF) {
		sprintf((char *)&printBuf[1], "%-12s: %s\n", "NO.KONTRAK", pobTran->szInputNumber_1);		
		retVal = p3300_print(hPrinter, printBuf);
		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE], 20);
		vdTrimSpace(buff);
		sprintf((char *)&printBuf[1], "%-12s: %s\n", "NAMA", buff);		
		retVal = p3300_print(hPrinter, printBuf);
		
			memset(buff, 0x00, sizeof(buff));
			strncpy(buff, &pobTran->szF48[(1*26)+49+F48_ADD_SIZE], 26);	
			buff[11] = 0x00;
			sprintf((char *)&printBuf[1], "%-12s: %s\n", "ANGSURAN", buff);					
			retVal = p3300_print(hPrinter, printBuf);		

		memset(buff , 0x00, sizeof(buff ));
		memset(buff2, 0x00, sizeof(buff2));
		memset(szCurr, 0x00, sizeof(szCurr));
		strncpy(buff, &pobTran->szF48[63+F48_ADD_SIZE], 12);
		FormatNumberWithCentEngl(buff2, buff);
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		if (!strcmp(szCurr, "RP.")) {
			FormatNumberWithCentInd(buff2, buff);
			if (strlen(buff2)>=3) buff2[strlen(buff2)-3] = 0x00;
		}
		sprintf((char *)&printBuf[1], "%-12s: %s %20s\n", "TAGIHAN", szCurr, buff2);		
		//retVal = p3300_print(hPrinter, printBuf);

		memset(buff, 0x00, sizeof(buff));
		memset(szCurr, 0x00, sizeof(szCurr));
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		FormatNumberWithCentEngl(buff, pobTran->szTotal);
		if (!strcmp(szCurr, "RP.")) {
			FormatNumberWithCentInd(buff, pobTran->szTotal);
			if (strlen(buff)>=3) buff[strlen(buff)-3] = 0x00;
		}
		sprintf((char *)&printBuf[1], "%-12s: %s %20s\n\n", "PEMBAYARAN", szCurr, buff);		
		retVal = p3300_print(hPrinter, printBuf);

	} else if (pobTran->inOriginalCode == PMT_TRX_CICILAN_SCB) {
		sprintf((char *)&printBuf[1], "%-12s: %s\n", "NO.KONTRAK", &pobTran->szInputNumber_1[3]);		
		retVal = p3300_print(hPrinter, printBuf);

		memset(buff, 0x00, sizeof(buff));
		FormatNumInd(buff, pobTran->Total);
		sprintf((char *)&printBuf[1], "%-12s: RP. %17s\n\n", "PEMBAYARAN", buff);		
		retVal = p3300_print(hPrinter, printBuf);

	} else if (pobTran->inOriginalCode == PMT_TRX_CICILAN_CITI) {
		sprintf((char *)&printBuf[1], "%-12s: %s\n", "NO.KONTRAK", pobTran->szInputNumber_1);		
		retVal = p3300_print(hPrinter, printBuf);

		memset(buff, 0x00, sizeof(buff));
		FormatNumInd(buff, pobTran->Total);
		sprintf((char *)&printBuf[1], "%-15s: RP. %17s\n\n", "PEMBAYARAN", buff);		
		retVal = p3300_print(hPrinter, printBuf);
	} else if (pobTran->inOriginalCode == PMT_TRX_CICILAN_ADIRA) {
		sprintf((char *)&printBuf[1], "%-12s: %s\n", "NO.KONTRAK", pobTran->szInputNumber_1);		
		retVal = p3300_print(hPrinter, printBuf);
		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE], 20);
		vdTrimSpace(buff);
		sprintf((char *)&printBuf[1], "%-12s: %s\n", "NAMA", buff);		
		retVal = p3300_print(hPrinter, printBuf);
		
			memset(buff, 0x00, sizeof(buff));
			strncpy(buff, &pobTran->szF48[(1*26)+49+F48_ADD_SIZE], 26);	
			buff[4] = 0x00;
			sprintf((char *)&printBuf[1], "%-12s: %02d\n", "ANGSURAN", atoi(buff));					
			retVal = p3300_print(hPrinter, printBuf);		

		memset(buff , 0x00, sizeof(buff ));
		memset(buff2, 0x00, sizeof(buff2));
		memset(szCurr, 0x00, sizeof(szCurr));
		strncpy(buff, &pobTran->szF48[63+F48_ADD_SIZE], 12);
		FormatNumberWithCentEngl(buff2, buff);
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		if (!strcmp(szCurr, "RP.")) {
			FormatNumberWithCentInd(buff2, buff);
			if (strlen(buff2)>=3) buff2[strlen(buff2)-3] = 0x00;
		}
		sprintf((char *)&printBuf[1], "%-12s: %s %20s\n", "TAGIHAN", szCurr, buff2);		
		retVal = p3300_print(hPrinter, printBuf);

		memset(buff, 0x00, sizeof(buff));
		memset(szCurr, 0x00, sizeof(szCurr));
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		FormatNumberWithCentEngl(buff, pobTran->szTotal);
		if (!strcmp(szCurr, "RP.")) {
			FormatNumberWithCentInd(buff, pobTran->szTotal);
			if (strlen(buff)>=3) buff[strlen(buff)-3] = 0x00;
		}
		sprintf((char *)&printBuf[1], "%-12s: %s %20s\n\n", "BAYAR", szCurr, buff);		
		retVal = p3300_print(hPrinter, printBuf);

	} else if (pobTran->inOriginalCode == PMT_TRX_BAYAR_PENDIDIKAN) {
		if (strncmp(pobTran->szInputNumber_1, "050", 3)) {  //non UI
			sprintf((char *)&printBuf[1], "%-12s: %s\n", "NO.IDENTITAS", &pobTran->szInputNumber_1[3]);		
		} else {
			memset(buff, 0x00, sizeof(buff));
			strncpy(buff, &pobTran->szF48[26+49+F48_ADD_SIZE-26], 11);
			sprintf((char *)&printBuf[1], "%-12s: %s\n", "NO.IDENTITAS", buff);		
		}

		retVal = p3300_print(hPrinter, printBuf);
		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE], 28);
		vdTrimSpace(buff);
		sprintf((char *)&printBuf[1], "%-12s: %s\n", "NAMA", buff);		
		retVal = p3300_print(hPrinter, printBuf);

		for (i=1; (F48_ADD_SIZE+49+(i+1)*26)<=strlen(pobTran->szF48); i++) {
			memset(buff, 0x00, sizeof(buff));
			strncpy(buff, &pobTran->szF48[(i*26)+49+F48_ADD_SIZE], 26);
			memset(buff2, 0x00, sizeof(buff2));
			memset(szCurr, 0x00, sizeof(szCurr));
			vdGetCurrency(szCurr, &buff[11]);
			FormatNumberWithCentEngl(buff2, &buff[14]);
			if (strlen(buff2)==4 && atoi(buff2)==0 && atoi(&buff2[2])==0) continue;
			if (!strcmp(szCurr, "RP.")) {
				FormatNumberWithCentInd(buff2, &buff[14]);
				if (strlen(buff2)>=3) buff2[strlen(buff2)-3] = 0x00;
			}
			buff[11] = 0x00;
			if (strncmp(pobTran->szInputNumber_1, "050", 3)) {  //non UI
				sprintf((char *)&printBuf[1], "%-12s: %s %20s\n", buff, szCurr, buff2);					
			} else {
				sprintf((char *)&printBuf[1], "%-12s: %s\n", "REF TGH", buff);					
			}
			retVal = p3300_print(hPrinter, printBuf);		
		}

		memset(buff , 0x00, sizeof(buff ));
		memset(buff2, 0x00, sizeof(buff2));
		memset(szCurr, 0x00, sizeof(szCurr));
		strncpy(buff, &pobTran->szF48[63+F48_ADD_SIZE], 12);
		FormatNumberWithCentEngl(buff2, buff);
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		if (!strcmp(szCurr, "RP.")) {
			FormatNumberWithCentInd(buff2, buff);
			if (strlen(buff2)>=3) buff2[strlen(buff2)-3] = 0x00;
		}
		if (strncmp(pobTran->szInputNumber_1, "050", 3)) {  //non UI
			sprintf((char *)&printBuf[1], "%-12s: %s %20s\n", "TAGIHAN", szCurr, buff2);		
			retVal = p3300_print(hPrinter, printBuf);
		}

		memset(buff, 0x00, sizeof(buff));
		memset(szCurr, 0x00, sizeof(szCurr));
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		FormatNumberWithCentEngl(buff, pobTran->szTotal);
		if (!strcmp(szCurr, "RP.")) {
			FormatNumberWithCentInd(buff, pobTran->szTotal);
			if (strlen(buff)>=3) buff[strlen(buff)-3] = 0x00;
		}
		sprintf((char *)&printBuf[1], "%-12s: %s %20s\n\n", "PEMBAYARAN", szCurr, buff);		
		retVal = p3300_print(hPrinter, printBuf);
	} else if (pobTran->inOriginalCode == PMT_TRX_BAYAR_ASURANSI) {

		//sprintf((char *)&printBuf[1], "%-12s: %s\n", "NO.POLIS", pobTran->szInputNumber_1);		
		sprintf((char *)&printBuf[1], "%-12s: %s\n", "NO.POLIS", &pobTran->szInputNumber_1[3]);		
		retVal = p3300_print(hPrinter, printBuf);
		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE], 20);
		vdTrimSpace(buff);
		sprintf((char *)&printBuf[1], "%-12s: %s\n", "NAMA", buff);		
		retVal = p3300_print(hPrinter, printBuf);

		for (i=1; (F48_ADD_SIZE+49+(i+1)*26)<=strlen(pobTran->szF48); i++) {
			memset(buff, 0x00, sizeof(buff));
			strncpy(buff, &pobTran->szF48[(i*26)+49+F48_ADD_SIZE], 26);
			memset(buff2, 0x00, sizeof(buff2));
			memset(szCurr, 0x00, sizeof(szCurr));
			vdGetCurrency(szCurr, &buff[11]);
			FormatNumberWithCentEngl(buff2, &buff[14]);
			if (strlen(buff2)==4 && atoi(buff2)==0 && atoi(&buff2[2])==0) continue;
			if (!strcmp(szCurr, "RP.")) {
				FormatNumberWithCentInd(buff2, &buff[14]);
				if (strlen(buff2)>=3) buff2[strlen(buff2)-3] = 0x00;
			}
			buff[11] = 0x00;
			sprintf((char *)&printBuf[1], "%-12s: %s %20s\n", buff, szCurr, buff2);					
			retVal = p3300_print(hPrinter, printBuf);		
		}
		
		memset(buff, 0x00, sizeof(buff));
		memset(szCurr, 0x00, sizeof(szCurr));
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		FormatNumberWithCentEngl(buff, pobTran->szTotal);
		if (!strcmp(szCurr, "RP.")) {
			FormatNumberWithCentInd(buff, pobTran->szTotal);
			if (strlen(buff)>=3) buff[strlen(buff)-3] = 0x00;
		}
		sprintf((char *)&printBuf[1], "%-12s: %s %20s\n\n", "TOTAL", szCurr, buff);		
		retVal = p3300_print(hPrinter, printBuf);
	} else if (pobTran->inOriginalCode == PMT_TRX_BAYAR_TIKET) {

		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[4], 18);  //get from F48 instead of pobTran->szInputNumber_1
		vdTrimSpace(buff);
		sprintf((char *)&printBuf[1], "%-12s: %s\n", "KODE BAYAR", buff);		
		retVal = p3300_print(hPrinter, printBuf);

		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE+27+(4*26)], 15);
		vdTrimSpace(buff);
		sprintf((char *)&printBuf[1], "%-12s: %s\n", "KODE BOOKING", buff);		
		retVal = p3300_print(hPrinter, printBuf);

		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE], 20);
		vdTrimSpace(buff);
		sprintf((char *)&printBuf[1], "%-12s: %s\n", "NAMA", buff);		
		retVal = p3300_print(hPrinter, printBuf);

		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE+27+(4*26)+15], 2);
		vdTrimSpace(buff);
		sprintf((char *)&printBuf[1], "%-12s: %s\n", "JML.SEAT", buff);		
		retVal = p3300_print(hPrinter, printBuf);

		memset(buff, 0x00, sizeof(buff));
		memset(szCurr, 0x00, sizeof(szCurr));
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		FormatNumberWithCentEngl(buff, pobTran->szTotal);
		if (!strcmp(szCurr, "RP.")) {
			FormatNumberWithCentInd(buff, pobTran->szTotal);
			if (strlen(buff)>=3) buff[strlen(buff)-3] = 0x00;
		}
		sprintf((char *)&printBuf[1], "%-12s: %s %20s\n\n", "TOTAL", szCurr, buff);		
		retVal = p3300_print(hPrinter, printBuf);

		sprintf((char *)&printBuf[1], "%s\n", "NOMOR PENERBANGAN");		
		retVal = p3300_print(hPrinter, printBuf);

		for (i=0; (F48_ADD_SIZE+49+119+(i+1)*23)<=strlen(pobTran->szF48); i++) {
			memset(buff2, 0x00, sizeof(buff2));
			strncpy(buff2, &pobTran->szF48[(i*23)+119+49+F48_ADD_SIZE], 23);
		    memset(buff, 0x00, sizeof(buff));  
			strncpy(buff, &buff2[2],  2);  //Carrier
			strncat(buff, &buff2[11], 4);  //Flight Number
			strncat(buff, "    ", 2);
			strncat(buff, &buff2[4], 1);   //Class
			strncat(buff, "    ", 2);
			strncat(buff, &buff2[5], 3);   //From
			strncat(buff, "-", 1);
			strncat(buff, &buff2[8], 3);   //To
			strncat(buff, "    ", 2);
			strncat(buff, &buff2[15], 2);  //Date: DD
			strncat(buff, "/", 1);
			strncat(buff, &buff2[17], 2);  //Date: MM
			strncat(buff, "    ", 2);
			strncat(buff, &buff2[19], 2);  //Time: hh
			strncat(buff, ":", 1);
			strncat(buff, &buff2[21], 2);  //Time: mm
			sprintf((char *)&printBuf[1], "%s\n", buff);					
			retVal = p3300_print(hPrinter, printBuf);		
		}
		sprintf((char *)&printBuf[1], "%s\n", " ");		
		retVal = p3300_print(hPrinter, printBuf);

	} else if (pobTran->inOriginalCode == PMT_TRX_BAYAR_PAYID) {
		sprintf((char *)&printBuf[1], "%-12s: %s\n", "NO.CUST", pobTran->szInputNumber_1);		
		retVal = p3300_print(hPrinter, printBuf);
		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22+F48_ADD_SIZE], 20);
		vdTrimSpace(buff);
		sprintf((char *)&printBuf[1], "%-12s: %s\n", "NAMA", buff);		
		retVal = p3300_print(hPrinter, printBuf);

		for (i=1; (F48_ADD_SIZE+49+(i+1)*26)<=strlen(pobTran->szF48); i++) {
			memset(buff, 0x00, sizeof(buff));
			strncpy(buff, &pobTran->szF48[(i*26)+49+F48_ADD_SIZE], 26);
			memset(buff2, 0x00, sizeof(buff2));
			memset(szCurr, 0x00, sizeof(szCurr));
			vdGetCurrency(szCurr, &buff[11]);
			FormatNumberWithCentEngl(buff2, &buff[14]);
			if (strlen(buff2)==4 && atoi(buff2)==0 && atoi(&buff2[2])==0) continue;
			if (!strcmp(szCurr, "RP.")) {
				FormatNumberWithCentInd(buff2, &buff[14]);
				if (strlen(buff2)>=3) buff2[strlen(buff2)-3] = 0x00;
			}
			buff[11] = 0x00;
			sprintf((char *)&printBuf[1], "%-12s: %s %20s\n", buff, szCurr, buff2);					
			retVal = p3300_print(hPrinter, printBuf);		
		}

		memset(buff , 0x00, sizeof(buff ));
		memset(buff2, 0x00, sizeof(buff2));
		memset(szCurr, 0x00, sizeof(szCurr));
		strncpy(buff, &pobTran->szF48[63+F48_ADD_SIZE], 12);
		FormatNumberWithCentEngl(buff2, buff);
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		if (!strcmp(szCurr, "RP.")) {
			FormatNumberWithCentInd(buff2, buff);
			if (strlen(buff2)>=3) buff2[strlen(buff2)-3] = 0x00;
		}
		sprintf((char *)&printBuf[1], "%-12s: %s %20s\n", "TAGIHAN", szCurr, buff2);		
		retVal = p3300_print(hPrinter, printBuf);

		memset(buff, 0x00, sizeof(buff));
		memset(szCurr, 0x00, sizeof(szCurr));
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		FormatNumberWithCentEngl(buff, pobTran->szTotal);
		if (!strcmp(szCurr, "RP.")) {
			FormatNumberWithCentInd(buff, pobTran->szTotal);
			if (strlen(buff)>=3) buff[strlen(buff)-3] = 0x00;
		}
		sprintf((char *)&printBuf[1], "%-12s: %s %20s\n\n", "BAYAR", szCurr, buff);		
		retVal = p3300_print(hPrinter, printBuf);
	} else if (pobTran->inCode == PMT_TRX_BAYAR_CDTCARD) {
		sprintf((char *)&printBuf[1], "%-15s: %s\n", "NO.KARTU KREDIT", pobTran->szInputNumber_1);		
		retVal = p3300_print(hPrinter, printBuf);
		memset(buff, 0x00, sizeof(buff));
		FormatNumInd(buff, pobTran->Total);
		sprintf((char *)&printBuf[1], "%-15s: RP. %17s\n\n", "TOTAL", buff);		
		retVal = p3300_print(hPrinter, printBuf);
	} else if (pobTran->inOriginalCode==PMT_TRX_TRANSFER || pobTran->inOriginalCode==PMT_TRX_TRANSFER_REK_LAIN || pobTran->inOriginalCode==PMT_TRX_TRANSFER_BANK_LAIN){
		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[40], 30);
		vdTrimSpace(buff);
		sprintf((char *)&printBuf[1], "%-12s: %s\n", "TRANSFER KE", buff);		
		retVal = p3300_print(hPrinter, printBuf);

		if (pobTran->inOriginalCode == PMT_TRX_TRANSFER_BANK_LAIN) {
			memset(buff, 0x00, sizeof(buff));	
			strncpy(buff, &pobTran->szF48[70], 20);
			vdTrimSpace(buff);
			if (strlen(buff)) {
				sprintf((char *)&printBuf[1], "%-12s: %s\n", "BANK", buff);		
				retVal = p3300_print(hPrinter, printBuf);
			} else {
				char szInst[4];
				memset(szInst, 0x00, sizeof(szInst));
				strncpy(szInst, pobTran->szInputNumber_2, 3);
				if (atoi(szInst)==13) {
					sprintf((char *)&printBuf[1], "%-12s: %s\n", "BANK", "PERMATA");		
					retVal = p3300_print(hPrinter, printBuf);
				}
			}
		}
		memset(buff, 0x00, sizeof(buff));
		strncpy(buff, &pobTran->szF48[22], 18);
		sprintf((char *)&printBuf[1], "%-12s: %s\n", "NO.REK", buff);		
		retVal = p3300_print(hPrinter, printBuf);	
		memset(buff, 0x00, sizeof(buff));	
		strncpy(buff, &pobTran->szF48[4], 18);
		sprintf((char *)&printBuf[1], "%-12s: %s\n", "NO.REF", buff);		
		retVal = p3300_print(hPrinter, printBuf);

		memset(buff, 0x00, sizeof(buff));
		FormatNumInd(buff, pobTran->Total);
		sprintf((char *)&printBuf[1], "%-12s: RP. %20s\n", "TOTAL", buff);		
		retVal = p3300_print(hPrinter, printBuf);

		{
			memset(buff, 0x00, sizeof(buff));
			vdGetTrxFee(buff, pobTran);
			if (strlen(buff)) {
				sprintf((char *)&printBuf[1], "%-12s: RP. %20s\n", "BIAYA", buff);		
				retVal = p3300_print(hPrinter, printBuf);
			}
		} 

		sprintf((char *)&printBuf[1], " \n");		
		retVal = p3300_print(hPrinter, printBuf);
	}

//////////////////
	memset(buff, 0x00, sizeof(buff));
	printBuf[0] = PRINT_NORM;
	if (pobTran->inManual==1 && pobTran->Status==2) {
	   strcpy(buff, "(Manual Entry)");
	   vdFormatText(buff, 42, CENTERED);
       sprintf((char *)&printBuf[1], "%s\n\n", buff);
	   retVal = p3300_print(hPrinter, printBuf);
	}
	return 1;
}

int inPrintSignature(TRANSACTION_OBJECT *pobTran)
{
	int retVal;
	unsigned short usOffset;
	unsigned char printBuf[50];
	char buff[128];
	char buff2[128];
	int i, j;

	memset(buff, 0x00, sizeof(buff));
	memset(buff2, 0x00, sizeof(buff2));
	for (i=0; i<obTranMapCount; i++){
		if (pobTran->inCode == obTranMap[i].inCode) {
			if (pobTran->isOnUs) {
				strcpy(buff2, obTranMap[i].szFooter1);
			} else {
				strcpy(buff2, obTranMap[i].szFooter1B);
			}
			break;
		}
	}

	for (j=0; j<4; j++) {
		if (pobTran->isOnUs) {
			if (j==0) strcpy(buff2, obTranMap[i].szFooter1);
			if (j==1) strcpy(buff2, obTranMap[i].szFooter2);
			if (j==2) strcpy(buff2, obTranMap[i].szFooter3);
			if (j==3) strcpy(buff2, obTranMap[i].szFooter4);
		} else {
			if (j==0) strcpy(buff2, obTranMap[i].szFooter1B);
			if (j==1) strcpy(buff2, obTranMap[i].szFooter2B);
			if (j==2) strcpy(buff2, obTranMap[i].szFooter3B);
			if (j==3) strcpy(buff2, obTranMap[i].szFooter4B);
		}

		if (strlen(buff2)>42) {
			for (i=strlen(buff2)-1; i>=0; i--) {
				if (isspace(buff2[i]) && i<=42) {
					memset(buff, 0x00, sizeof(buff));
					strncpy(buff, buff2, i);
					vdFormatText(buff, 42, CENTERED);
					printBuf[0] = PRINT_NORM;
					sprintf((char *)&printBuf[1], "%s\n", buff);
					retVal = p3300_print(hPrinter, printBuf);
					strcpy(buff2, &buff2[i]);
					break;
				}
			}
		}
		buff2[42] = 0x00;
		memset(buff, 0x00, sizeof(buff));
		strcpy(buff, buff2);
		vdFormatText(buff, 42, CENTERED);
		printBuf[0] = PRINT_NORM;
		sprintf((char *)&printBuf[1], "%s\n", buff);
		if (strlen(buff2))
			retVal = p3300_print(hPrinter, printBuf);
	}
/*

	memset(buff, 0x00, sizeof(buff));
	printBuf[0] = PRINT_NORM;
	sprintf((char *)&printBuf[1], "\n\n");
	retVal = p3300_print(hPrinter, printBuf);

	memset((char *)&printBuf[1], 0x00, sizeof(printBuf)-1);
	sprintf((char *)&printBuf[1], "SIGN X____________________________________\n");
	retVal = p3300_print(hPrinter, printBuf);

	memset(buff, 0x00, sizeof(buff));
	get_env("FOOTER1", buff, sizeof(buff)-1);
	vdFormatText(buff, 42, CENTERED);
	sprintf((char *)&printBuf[1], "%s\n", buff);
	retVal = p3300_print(hPrinter, printBuf);
	memset(buff, 0x00, sizeof(buff));
	get_env("FOOTER2", buff, sizeof(buff)-1);
	vdFormatText(buff, 42, CENTERED);
	sprintf((char *)&printBuf[1], "%s\n", buff);
	retVal = p3300_print(hPrinter, printBuf);

	sprintf((char *)&printBuf[1], "\n");
	retVal = p3300_print(hPrinter, printBuf);    
*/
	return 1;
}

int inPrintFooter(TRANSACTION_OBJECT *pobTran)
{
	int retVal;
	unsigned short usOffset;
	unsigned char printBuf[50];
	char buff[128];
	char buff2[128];

	memset(buff, 0x00, sizeof(buff));
	printBuf[0] = PRINT_NORM;

	if (pobTran->inReceiptCopy == 1)
		strcpy(buff, "--Merchant Copy--");
	else if (pobTran->inReceiptCopy == 2)
		strcpy(buff, "--Bank Copy--");
	else if (pobTran->inReceiptCopy == 3)
		strcpy(buff, "--Customer Copy--");
	else
		strcpy(buff, "--Duplicate--");

	if (pobTran->inOriginalCode == PMT_TRX_BAYAR_PLN) {
		char szCurr[30];
		memset(buff, 0x00, sizeof(buff));
		memset(szCurr, 0x00, sizeof(szCurr));
		vdGetCurrency(szCurr, &pobTran->szF48[60+F48_ADD_SIZE]);
		FormatNumberWithCentEngl(buff, pobTran->szTotal);
		if (!strcmp(szCurr, "RP.")) {
			FormatNumberWithCentInd(buff, pobTran->szTotal);
			if (strlen(buff)>=3) buff[strlen(buff)-3] = 0x00;
		}
		sprintf((char *)&printBuf[1], "\n%-15s: %s %20s\n", "ADMIN BANK", szCurr, "0");		
		retVal = p3300_print(hPrinter, printBuf);
		sprintf((char *)&printBuf[1], "%-15s: %s %20s\n", "TOTAL", szCurr, buff);		
		retVal = p3300_print(hPrinter, printBuf);
	}

	strcpy(buff, "*** Terima Kasih ***");

	vdFormatText(buff, 42, CENTERED);
#ifdef __arm
	sprintf((char *)&printBuf[1], "\n%s\n\n", buff);
#else 
	sprintf((char *)&printBuf[1], "\n%s\n", buff);
#endif
	retVal = p3300_print(hPrinter, printBuf);
/*
	sprintf((char *)&printBuf[1], "------------------------------------------\n");
	retVal = p3300_print(hPrinter, printBuf);
	memset(buff, 0x00, sizeof(buff));
	memset((char *)&printBuf[1], 0x00, sizeof(printBuf)-1);
	FormatDate(buff, "");
	sprintf((char *)&printBuf[1], "Print %s, ", buff);
	FormatTime(buff, "");
	strcat((char *)&printBuf[1], buff);
	strcat((char *)&printBuf[1], "\n");
	retVal = p3300_print(hPrinter, printBuf);
*/
	return 1;
}

int inPrintShiftPaper(TRANSACTION_OBJECT *pobTran)
{
	int retVal;
	unsigned char printBuf[50];

	memset(printBuf, 0x00, sizeof(printBuf));
	printBuf[0] = PRINT_NORM;
	sprintf((char *)&printBuf[1], "\n\n\n\n\n");
	retVal = p3300_print(hPrinter, printBuf);
	return 1;
}

int PrintSummaryReport(char *TheDate)
{
	int retVal;
	unsigned short usOffset;
	unsigned char printBuf[50];
	char buff[128];
	char buff2[128];
	char DateBuff[20];

	int fhandle;
	int bytes, i, jj;
	int FirstRecord = 0;
	int IncompleteVoidReversalFound=0;
	TRANSACTION_OBJECT obTranLocal;

	for (jj=0; jj<obTranMapCount; jj++){
		obTranMap[jj].lnRevNum1 = 0;
		obTranMap[jj].lnRevNum2 = 0;
		obTranMap[jj].lnRevNum3 = 0;
	}
	memset((void *)&obTranLocal, 0x00, sizeof(TRANSACTION_OBJECT));
	if (strlen(TheDate)==0) {
		memset(buff, 0x00, sizeof(buff));
		SVC_CLOCK(0, buff, 15);
		strncpy(DateBuff, &buff[2], 6);
		DateBuff[6] = 0x00;
	} else {
		strcpy(DateBuff, TheDate);
	}
	if (GetLastTransactionRecord(2, &obTranLocal)==0) {
		return 0;
	}
	fhandle = open("BATCH", O_RDWR);
	if (fhandle == -1) return 0;
    FirstRecord = obTranLocal.RecordNo + 1;
	if (FirstRecord == 0) {
	  lseek(fhandle, (long)0, SEEK_SET);
	} else if (FirstRecord % BATCH_SIZE){
	  lseek(fhandle, (long)(((FirstRecord % BATCH_SIZE)-1)*sizeof(TRANSACTION_OBJECT)), SEEK_SET);
	} else {
	  lseek(fhandle, (long)((BATCH_SIZE-1)*sizeof(TRANSACTION_OBJECT)), SEEK_SET);
	}
	for (i=0; i<BATCH_SIZE; i++) {
		memset((void *)&obTranLocal, 0x00, sizeof(TRANSACTION_OBJECT));
		bytes = read(fhandle, (void *)&obTranLocal, sizeof(TRANSACTION_OBJECT));
		if (bytes != sizeof(TRANSACTION_OBJECT)) {
			lseek(fhandle, (long)0, SEEK_SET);
			read(fhandle, (void *)&obTranLocal, sizeof(TRANSACTION_OBJECT));
		}
		if ((obTranLocal.Status==2 || obTranLocal.Status==3) &&(!strcmp(DateBuff, obTranLocal.szDate))) {
			if (obTranLocal.Status==3) IncompleteVoidReversalFound=1;
			for (jj=0; jj<obTranMapCount; jj++){
				if (obTranLocal.inCode == obTranMap[jj].inCode) {
					obTranMap[jj].lnRevNum1 = obTranMap[jj].lnRevNum1 + 1;
					obTranMap[jj].lnRevNum2 = obTranMap[jj].lnRevNum2 + obTranLocal.Total;
					obTranMap[jj].lnRevNum3 = obTranMap[jj].lnRevNum3 + obTranLocal.Point;
					break;
				}
			}
		}
	}
	close(fhandle);	

	disable_hot_key();
	retVal = p3300_select_font(hPrinter, 0x04, 0);
	memset(printBuf, 0, sizeof(printBuf));
	printBuf[0] = PRINT_NORM;
	printBuf[0] = DBL_HEIGHT;
	memset(buff, 0x00, sizeof(buff));
	get_env(PRT_HEADER1, buff, sizeof(buff)-1);
	vdFormatText(buff, 32, CENTERED);
	retVal = p3300_select_font(hPrinter, 0x03, 0); // Set the printer default font to 8x14 at 32 column
    sprintf((char *)&printBuf[1], "%s\n", buff);
	retVal = p3300_print(hPrinter, printBuf);
	printBuf[0] = PRINT_NORM;
	memset(buff, 0x00, sizeof(buff));
	get_env(PRT_HEADER2, buff, sizeof(buff)-1);
	vdFormatText(buff, 24, CENTERED);
	retVal = p3300_select_font(hPrinter, 0x02, 0); // Set the printer default font to 5x8 at 24 column
	sprintf((char *)&printBuf[1], "%s\n", buff);
	retVal = p3300_print(hPrinter, printBuf);
	retVal = p3300_select_font(hPrinter, 0x04, 0); // Set the printer default font back to 8x14 at 42
	memset(buff, 0x00, sizeof(buff));
	get_env(PRT_HEADER3, buff, sizeof(buff)-1);
	vdFormatText(buff, 42, CENTERED);
	sprintf((char *)&printBuf[1], "%s\n\n", buff);
	retVal = p3300_print(hPrinter, printBuf);

	memset(buff, 0x00, sizeof(buff));
	memset(buff2, 0x00, sizeof(buff2));
	get_env_x(HOST_TERMINAL, 0, buff);
	sprintf(buff2, "TERMINAL    : %s/", buff);
	memset(buff, 0x00, sizeof(buff));
	get_env_x(HOST_TERMINAL, 1, buff);
	strcat(buff2, buff);
	sprintf((char *)&printBuf[1], "%s\n", buff2);
	retVal = p3300_print(hPrinter, printBuf);

	memset(buff, 0x00, sizeof(buff));
	memset(buff2, 0x00, sizeof(buff2));
	memset((char *)&printBuf[1], 0x00, sizeof(printBuf)-1);
	if (strlen(TheDate)==0) {
		FormatDate(buff, "");
		FormatTime(buff2, "");
		sprintf((char *)&printBuf[1], "REPORT DATE : %s, %s\n\n, ", buff, buff2);
	} else {
		buff2[0] = 0x00;
		sprintf(buff, "%c%c/%c%c/%c%c", TheDate[4],TheDate[5],TheDate[2],TheDate[3],TheDate[0],TheDate[1]);
		sprintf((char *)&printBuf[1], "REPORT DATE : %s\n\n, ", buff);
	}
	retVal = p3300_print(hPrinter, printBuf);

	printBuf[0] = DBL_WIDTH;
	strcpy(buff, "SUMMARY REPORT");
	vdFormatText(buff, 21, CENTERED);
    sprintf((char *)&printBuf[1], "%s\n", buff);
	retVal = p3300_print(hPrinter, printBuf);

	printBuf[0] = PRINT_NORM;
    sprintf((char *)&printBuf[1], "------------------------------------------\n");
	retVal = p3300_print(hPrinter, printBuf);
    sprintf((char *)&printBuf[1], "                   COUNT         TOTAL    \n");
	retVal = p3300_print(hPrinter, printBuf);
	sprintf((char *)&printBuf[1], "------------------------------------------\n");
	retVal = p3300_print(hPrinter, printBuf);

	for (jj=0; jj<obTranMapCount; jj++){
		if (obTranMap[jj].lnRevNum1 > 0) {
			memset(buff, 0x00, sizeof(buff));
			FormatNumInd(buff, obTranMap[jj].lnRevNum2);
			if (obTranMap[jj].lnRevNum3>0) {
				//obTranMap[jj].szCode[16] = 0x00;
				sprintf((char *)&printBuf[1], "%-16s %3ld %3ldP|RP %13s\n", obTranMap[jj].szCode, obTranMap[jj].lnRevNum1, obTranMap[jj].lnRevNum3, buff);
			} else {
				//obTranMap[jj].szCode[16] = 0x00;
				sprintf((char *)&printBuf[1], "%-21s %3ld    %13s\n", obTranMap[jj].szCode, obTranMap[jj].lnRevNum1, buff);
			}
			retVal = p3300_print(hPrinter, printBuf);
		}
	}
    sprintf((char *)&printBuf[1], "------------------------------------------\n");
	retVal = p3300_print(hPrinter, printBuf);
	if (IncompleteVoidReversalFound) {
	   sprintf((char *)&printBuf[1], "(Note: One Incomplete Reversal of Void)\n\n\n\n\n\n\n\n\n\n\n\n\n");
	   retVal = p3300_print(hPrinter, printBuf);
	} else {
	   sprintf((char *)&printBuf[1], " \n\n\n\n\n\n\n\n\n\n\n\n");
	   retVal = p3300_print(hPrinter, printBuf);
	}

}


int PrintDetailReport(char *TheDate)
{
	int retVal;
	unsigned short usOffset;
	unsigned char printBuf[128];
	char buff[128];
	char buff2[128];
	char DateBuff[20];
	char szCurr[30];

	int fhandle;
	int bytes, i, jj;
	int FirstRecord = 0;
	unsigned long ElCount=0L, ElTotal=0L, PymCount=0L, PymTotal=0L; 
	TRANSACTION_OBJECT obTranLocal;
	memset((void *)&obTranLocal, 0x00, sizeof(TRANSACTION_OBJECT));
	if (strlen(TheDate)==0) {
		memset(buff, 0x00, sizeof(buff));
		SVC_CLOCK(0, buff, 15);
		strncpy(DateBuff, &buff[2], 6);
		DateBuff[6] = 0x00;
	} else {
		strcpy(DateBuff, TheDate);
	}
	if (GetLastTransactionRecord(2, &obTranLocal)==0) {
		return 0;
	}
	fhandle = open("BATCH", O_RDWR);
	if (fhandle == -1) return 0;
    FirstRecord = obTranLocal.RecordNo + 1;
	if (FirstRecord == 0) {
	  lseek(fhandle, (long)0, SEEK_SET);
	} else if (FirstRecord % BATCH_SIZE){
	  lseek(fhandle, (long)(((FirstRecord % BATCH_SIZE)-1)*sizeof(TRANSACTION_OBJECT)), SEEK_SET);
	} else {
	  lseek(fhandle, (long)((BATCH_SIZE-1)*sizeof(TRANSACTION_OBJECT)), SEEK_SET);
	}

	disable_hot_key();
	retVal = p3300_select_font(hPrinter, 0x04, 0);
	memset(printBuf, 0, sizeof(printBuf));
	printBuf[0] = PRINT_NORM;
	printBuf[0] = DBL_HEIGHT;
	memset(buff, 0x00, sizeof(buff));
	get_env(PRT_HEADER1, buff, sizeof(buff)-1);
	vdFormatText(buff, 32, CENTERED);
	retVal = p3300_select_font(hPrinter, 0x03, 0); // Set the printer default font to 8x14 at 32 column
    sprintf((char *)&printBuf[1], "%s\n", buff);
	retVal = p3300_print(hPrinter, printBuf);
	printBuf[0] = PRINT_NORM;
	memset(buff, 0x00, sizeof(buff));
	get_env(PRT_HEADER2, buff, sizeof(buff)-1);
	vdFormatText(buff, 24, CENTERED);
	retVal = p3300_select_font(hPrinter, 0x02, 0); // Set the printer default font to 5x8 at 24 column
	sprintf((char *)&printBuf[1], "%s\n", buff);
	retVal = p3300_print(hPrinter, printBuf);
	retVal = p3300_select_font(hPrinter, 0x04, 0); // Set the printer default font back to 8x14 at 42
	memset(buff, 0x00, sizeof(buff));
	get_env(PRT_HEADER3, buff, sizeof(buff)-1);
	vdFormatText(buff, 42, CENTERED);
	sprintf((char *)&printBuf[1], "%s\n\n", buff);
	retVal = p3300_print(hPrinter, printBuf);
	memset(buff, 0x00, sizeof(buff));
	memset(buff2, 0x00, sizeof(buff2));
	get_env_x(HOST_TERMINAL, 0, buff);
	sprintf(buff2, "TERMINAL    : %s/", buff);
	memset(buff, 0x00, sizeof(buff));
	get_env_x(HOST_TERMINAL, 1, buff);
	strcat(buff2, buff);
	sprintf((char *)&printBuf[1], "%s\n", buff2);
	retVal = p3300_print(hPrinter, printBuf);
	memset(buff, 0x00, sizeof(buff));
	memset(buff2, 0x00, sizeof(buff2));
	memset((char *)&printBuf[1], 0x00, sizeof(printBuf)-1);
	if (strlen(TheDate)==0) {
		FormatDate(buff, "");
		FormatTime(buff2, "");
		sprintf((char *)&printBuf[1], "REPORT DATE : %s, %s\n\n, ", buff, buff2);
	} else {
		buff2[0] = 0x00;
		sprintf(buff, "%c%c/%c%c/%c%c", TheDate[4],TheDate[5],TheDate[2],TheDate[3],TheDate[0],TheDate[1]);
		sprintf((char *)&printBuf[1], "REPORT DATE : %s\n\n, ", buff);
	}
	retVal = p3300_print(hPrinter, printBuf);


	printBuf[0] = DBL_WIDTH;
	strcpy(buff, "DETAIL  REPORT");
	vdFormatText(buff, 21, CENTERED);
    sprintf((char *)&printBuf[1], "%s\n", buff);
	retVal = p3300_print(hPrinter, printBuf);

	printBuf[0] = PRINT_NORM;
    sprintf((char *)&printBuf[1], "------------------------------------------\n");
	retVal = p3300_print(hPrinter, printBuf);

	for (i=0; i<BATCH_SIZE; i++) {
		memset((void *)&obTranLocal, 0x00, sizeof(TRANSACTION_OBJECT));
		bytes = read(fhandle, (void *)&obTranLocal, sizeof(TRANSACTION_OBJECT));
		if (bytes != sizeof(TRANSACTION_OBJECT)) {
			lseek(fhandle, (long)0, SEEK_SET);
			read(fhandle, (void *)&obTranLocal, sizeof(TRANSACTION_OBJECT));
		}
		if ((obTranLocal.Status==2 || obTranLocal.Status==3) &&(!strcmp(DateBuff, obTranLocal.szDate))) {
			if (obTranLocal.Status==3) {
			   memset(buff, 0x00, sizeof(buff));
			   printBuf[0] = PRINT_NORM;
               sprintf((char *)&printBuf[1], "(Incomplete Reversal of Void)\n");
	           retVal = p3300_print(hPrinter, printBuf);
			}
			memset(buff, 0x00, sizeof(buff));
			//printBuf[0] = DBL_WIDTH;
			//printBuf[0] = PRINT_NORM;
			printBuf[0] = DBL_HEIGHT;
			for (jj=0; jj<obTranMapCount; jj++){
				if (obTranLocal.inCode == obTranMap[jj].inCode) {
					//obTranMap[jj].szCode[18] = 0x00;
					{	
						if (obTranLocal.inCode==PMT_TRX_PURCHASE
							|| obTranLocal.inCode == PMT_TRX_BAYAR_CDTCARD
							|| obTranLocal.inOriginalCode==PMT_TRX_TRANSFER || obTranLocal.inOriginalCode==PMT_TRX_TRANSFER_REK_LAIN || obTranLocal.inOriginalCode==PMT_TRX_TRANSFER_BANK_LAIN) {
								memset(buff, 0x00, sizeof(buff));
								FormatNumInd(buff, obTranLocal.Total);
								sprintf((char *)&printBuf[1], "%-21s    RP.%14s\n", obTranMap[jj].szCode, buff);		
								//retVal = p3300_print(hPrinter, printBuf);
						} else if (obTranLocal.inCode==PMT_TRX_ISI_ULANG) {
							memset(buff, 0x00, sizeof(buff));
							FormatNumInd(buff, obTranLocal.lnVoucherAmt);
							sprintf((char *)&printBuf[1], "%-21s    RP.%14s\n", obTranMap[jj].szCode, buff);		
							//retVal = p3300_print(hPrinter, printBuf);
						} else if (obTranLocal.inOriginalCode == PMT_TRX_BAYAR_TELPON 
							|| obTranLocal.inOriginalCode == PMT_TRX_BAYAR_PLN
							|| obTranLocal.inOriginalCode == PMT_TRX_BAYAR_PALYJA
							|| obTranLocal.inOriginalCode == PMT_TRX_BAYAR_PAM
							|| obTranLocal.inOriginalCode == PMT_TRX_CICILAN_ACC
							|| obTranLocal.inOriginalCode == PMT_TRX_CICILAN_FIF
							|| obTranLocal.inOriginalCode == PMT_TRX_CICILAN_TAF
							|| obTranLocal.inOriginalCode == PMT_TRX_CICILAN_SCB
							|| obTranLocal.inOriginalCode == PMT_TRX_CICILAN_CITI
							|| obTranLocal.inOriginalCode == PMT_TRX_CICILAN_ADIRA
							|| obTranLocal.inOriginalCode == PMT_TRX_BAYAR_PENDIDIKAN
							|| obTranLocal.inOriginalCode == PMT_TRX_BAYAR_ASURANSI
							|| obTranLocal.inOriginalCode == PMT_TRX_BAYAR_TIKET
							|| obTranLocal.inOriginalCode == PMT_TRX_BAYAR_PAYID ) {
								memset(buff, 0x00, sizeof(buff));
								memset(szCurr, 0x00, sizeof(szCurr));
								vdGetCurrency(szCurr, &obTranLocal.szF48[60+F48_ADD_SIZE]);
								FormatNumberWithCentEngl(buff, obTranLocal.szTotal);
								if (!strcmp(szCurr, "RP.")) {
									FormatNumberWithCentInd(buff, obTranLocal.szTotal);
									if (strlen(buff)>=3) buff[strlen(buff)-3] = 0x00;
								}
								sprintf((char *)&printBuf[1], "%-21s    %s%14s\n", obTranMap[jj].szCode, szCurr, buff);		
								//retVal = p3300_print(hPrinter, printBuf);
						} else {
							FormatNumInd(buff, obTranLocal.Total);
							if (obTranLocal.Point>0) {
								sprintf((char *)&printBuf[1], "%-18s %03ldP  RP %14s\n", 
									obTranMap[jj].szCode, obTranLocal.Point, buff);	
							} else {
								sprintf((char *)&printBuf[1], "%-21s    RP %14s\n", 
									obTranMap[jj].szCode, buff);	
							}
						}
					}
					break;
				}
			}
			retVal = p3300_print(hPrinter, printBuf);

			printBuf[0] = PRINT_NORM;
			memset(buff, 0x00, sizeof(buff));
			FormatDate(buff, obTranLocal.szExpDate);
			sprintf((char *)&printBuf[1], "%-22s EXP   : %11s\n", obTranLocal.szPAN, buff);
			retVal = p3300_print(hPrinter, printBuf);
			//sprintf((char *)&printBuf[1], "TR/REC: %04d/%04d      TRACE :      %06ld\n", obTranLocal.STAN, obTranLocal.RecordNo, obTranLocal.lnInvNum);
			sprintf((char *)&printBuf[1],   "STAN  : %06d         TRACE :      %06ld\n", obTranLocal.STAN, obTranLocal.lnInvNum);
			retVal = p3300_print(hPrinter, printBuf);
			memset(buff, 0x00, sizeof(buff));
			memset(buff2, 0x00, sizeof(buff2));
			FormatDate(buff, obTranLocal.szDate);
			FormatTime(buff2, obTranLocal.szTime);
			sprintf((char *)&printBuf[1], "DATE  : %-12s   TIME  : %11s\n", buff, buff2);
			retVal = p3300_print(hPrinter, printBuf);
			sprintf((char *)&printBuf[1], "REF#  : %-12s   APPR. : %11s\n", obTranLocal.szRetRefNum, obTranLocal.szAuthCode);
			retVal = p3300_print(hPrinter, printBuf);

			printBuf[0] = PRINT_NORM;
			memset(buff2, 0x00, sizeof(buff2));
/*
			if (obTranLocal.inCode==TRX_TRANSFER) {
				sprintf(buff2, "Ke Rekening\nA.N     : %s\nNo. Rek : %s\n", obTranLocal.szRcptName, obTranLocal.szRcptAcc);
			} else if (obTranLocal.inCode==TRX_PAY_CC_STD) { 
				sprintf(buff2, "Untuk\nIssuer : %s\nCard # : %s\n", obTranLocal.szRcptName, obTranLocal.szRcptAcc);
			} else if (obTranLocal.inCode==TRX_PAY_PLN) {
				sprintf(buff2, "Tagihan\nA.N : %s\nID. : %s\n", obTranLocal.szRcptName, obTranLocal.szRcptAcc);
			} else if (obTranLocal.inCode==TRX_PAY_LLPHONE_STD) {
				sprintf(buff2, "Tagihan\nProvider : %s\nA/N      : %s\nPhone #  : %s\n", obTranLocal.szInfo, obTranLocal.szRcptName, obTranLocal.szRcptAcc);
			} else if (obTranLocal.inCode==TRX_PAY_HPHONE_STD) {
				sprintf(buff2, "Tagihan\nProvider  : %s\nHandphone : %s\n", obTranLocal.szRcptName, obTranLocal.szRcptAcc);
			} else if (obTranLocal.inCode==TRX_TOPUP_STD) {
				sprintf(buff2, "TOPUP\nJenis Kartu : %s\nHandphone   : %s\n", obTranLocal.szRcptName, obTranLocal.szRcptAcc);
			} else if (obTranLocal.inCode==TRX_BUY_VOUCHERHP_STD) {
				sprintf(buff2, "VOUCHER\nJenis Kartu : %s\nNo. Voucher : %s\n", obTranLocal.szRcptName, obTranLocal.szRcptAcc);
			} else if (obTranLocal.inCode==TRX_MINI_STATEMENT) {
			}
			if (strlen(obTranLocal.szRcptAcc) > 0) {
				strcpy((char *)&printBuf[1], buff2);
				retVal = p3300_print(hPrinter, printBuf);
			}
			strcpy((char *)&printBuf[1], "\n");
			retVal = p3300_print(hPrinter, printBuf);
*/
		}
	}
	close(fhandle);	
	sprintf((char *)&printBuf[1], "------------------------------------------\n\n\n\n\n\n");
	retVal = p3300_print(hPrinter, printBuf);
}


int CreateBatchRecord(void)
{
	int fhandle;
	long countbyte;
	char buffer[128];
	TRANSACTION_OBJECT pobTran;
	int i;

	memset((void *)&pobTran, 0x00, sizeof(TRANSACTION_OBJECT));
	memset(buffer, 0x00, sizeof(buffer));
	if (get_env("#CZE" , buffer, sizeof(buffer)-1)>0) {
		if (buffer[0] == '1') {
			fhandle = open("BATCH", O_CREAT|O_TRUNC|O_RDWR);
			if (fhandle != -1) {
				for (i=0; i<BATCH_SIZE; i++) {
					pobTran.RecordNo = 0;
					countbyte = write(fhandle, (const void *)&pobTran, sizeof(TRANSACTION_OBJECT));
					if (countbyte == sizeof(TRANSACTION_OBJECT)) {
						sprintf(buffer, "Batch #%d x %ld", i+1, countbyte);
						DisplayStatus(buffer);
						//SVC_WAIT(100);
						//LOG_PRINTFF((0x08L,"%s", buffer));
					}else {
						sprintf(buffer, "Not Enough Memory!");
						write_at((const char *)buffer, strlen(buffer), 1, 7);
						LOG_PRINTFF((0x08L,"Not Enough Memory, MAX BATCH = %d", i));
						LOG_PRINTFF((0x08L,"Not Enough Memory, MAX BATCH = %d", i));
						LOG_PRINTFF((0x08L,"Not Enough Memory, MAX BATCH = %d", i));
						while(1);
					}
				}	
			}
			close(fhandle);
			put_env("#CZE", "0", 1);
		}
	}
	return 1;
}

int ChooseBatchRecord(unsigned long lnInv, int Status, TRANSACTION_OBJECT *pobTran)
{
	int karakter=0;  
	int fhandle;
	int i = 0;
	int line = 0;
	int found = 0;
	int bytes;
	int PrevRecordNo=0;
	int LastTrxRecNo = 0;
	char buff[100];
	char buff2[100];
	char TimeBuff[20];	
	memset(TimeBuff, 0x00, sizeof(TimeBuff));
	SVC_CLOCK(0, TimeBuff, 15);

	fhandle = open("BATCH", O_RDWR);
	if (fhandle == -1) return 0;
	vdFlushKeyboardBuffer();
	do {
		memset((void *)pobTran, 0x00, sizeof(TRANSACTION_OBJECT));
		bytes = read(fhandle, (void *)pobTran, sizeof(TRANSACTION_OBJECT));
		//if ((pobTran->STAN==inSTAN) && (pobTran->Status==Status || (Status==2 && pobTran->Status==3)) && (!strncmp(pobTran->szDate, &TimeBuff[2], 6))){
		if ((pobTran->lnInvNum==lnInv) && (pobTran->Status==Status || (Status==2 && pobTran->Status==3))){
			found = 1;
			break;
		}
	}while (bytes == sizeof(TRANSACTION_OBJECT));

	if (!found) {
		display_at(1, 7, " ", CLR_EOL);
		write_at("Invalid Trace#!", 15, 1, 3);
		write_at("Continue ?", 10, 1, 4);
		write_at(" Yes"			, 4, 22-4, 6);
		write_at("  No"			, 4, 22-4, 8);
		set_font("F:asc8x21.vft");
		for(i=2; i<=8; i++) write_at("|", 1, 22-5, i);
		set_font("");
		TimeOut(15000);
		do {
			if (KBHIT()) {
				karakter = get_char();
				TimeOut(15000);
			} else {
				if (TimeOut(0)) {
					close(fhandle);
					return 0;
				}
				SVC_WAIT(0);
				if (lnInv) {
					continue;
				} else {
					ClearSevenLine();
					write_at("Last Transaction...", 19, 1, 6);
					karakter=0x03;
				}
			}
			if (karakter == 0x0D || karakter == 0x03) { //enter or F3
				lseek(fhandle, (long)0, SEEK_SET);
				do {
					memset((void *)pobTran, 0x00, sizeof(TRANSACTION_OBJECT));
					bytes = read(fhandle, (void *)pobTran, sizeof(TRANSACTION_OBJECT));
					if (bytes == sizeof(TRANSACTION_OBJECT)){
						if (PrevRecordNo==0 || pobTran->RecordNo == PrevRecordNo+1) {
							PrevRecordNo = pobTran->RecordNo;
						} else {
							break;
						}
						if (pobTran->Status == Status) LastTrxRecNo = pobTran->RecordNo; 
						if (Status==2 && pobTran->Status==3) LastTrxRecNo = pobTran->RecordNo;
					}else{
						break;
					}
				}while (1);
				PrevRecordNo = LastTrxRecNo;
				if (PrevRecordNo == 0) {
					lseek(fhandle, (long)0, SEEK_SET);
				} else if (PrevRecordNo % BATCH_SIZE){
					lseek(fhandle, (long)(((PrevRecordNo % BATCH_SIZE)-1)*sizeof(TRANSACTION_OBJECT)), SEEK_SET);
				} else {
					lseek(fhandle, (long)((BATCH_SIZE-1)*sizeof(TRANSACTION_OBJECT)), SEEK_SET);
				}
				read(fhandle, (void *)pobTran, sizeof(TRANSACTION_OBJECT));
				if (LastTrxRecNo==0) {
					close(fhandle);
					DisplayStatus("No Batch Trxn!");
					SVC_WAIT(2000);
					return 0;
				}
				break;
			} else if (karakter == 0x1B || karakter == 0x04) { //esc or F4
				close(fhandle);
				return 0;
			} 
		} while(1);
	}

	do {
		ClearSevenLine();
		write_at(" Yes"			, 4, 22-4, 4);
		write_at("  No"			, 4, 22-4, 6);
		write_at("Next"			, 4, 22-4, 8);
		set_font("F:asc8x21.vft");
		for(i=2; i<=8; i++) write_at("|", 1, 22-5, i);
		set_font("");

		line=2;
		memset(buff, 0x00, sizeof(buff));
		write_at(pobTran->szPAN, strlen(pobTran->szPAN), 1, line++);
		strcpy(buff, pobTran->szCHolder); buff[16] = 0x00;
		if (strlen(buff)) write_at(buff, strlen(buff), 1, line++);
		memset(buff, 0x00, sizeof(buff));
		for (i=0; i<obTranMapCount; i++){
			if (pobTran->inCode == obTranMap[i].inCode) {
				if (pobTran->Status==4) strcpy(buff, "Void ");
				strcat(buff, obTranMap[i].szCode);
				buff[16] = 0x00;
			}
		}
		write_at(buff, strlen(buff), 1, line++);
		//sprintf(buff, "Tr/Rec:%03d/%03d", pobTran->STAN, pobTran->RecordNo);
		sprintf(buff, "Trc: %06ld", pobTran->lnInvNum);
		write_at(buff, strlen(buff), 1, line++);
/*
		if (strlen(pobTran->szRcptAcc)) {
			sprintf(buff, "To :%s", pobTran->szRcptName);
			buff[16] = 0x00;
			write_at(buff, strlen(buff), 1, line++);
		}
*/
		if (pobTran->Point>0) {
			sprintf(buff, "Pax:%02ld", pobTran->Point);
			write_at(buff, strlen(buff), 1, line++);
		}
		if (pobTran->Total>0) {	
			memset(buff, 0x00, sizeof(buff));
			FormatNumInd(buff, pobTran->Total);
			write_at("RP : ", 5, 1, line);
			write_at(buff, strlen(buff), 6, line++);
		}

		TimeOut(15000);
		do { 
			if (KBHIT()) {
				karakter = get_char();
				break;
			}
			SVC_WAIT(0);
			if (TimeOut(0)) {
				close(fhandle);
				return 0;
			}
		}while(1);
		if (karakter == 0x0D || karakter == 0x02) { //enter or F2
			close(fhandle);
			return 1;
		} else if (karakter == 0x1B || karakter == 0x03) { //esc or F3
			close(fhandle);
			return 0;
		} else if (karakter == 0x04){ //F4
			for (i=0; i<BATCH_SIZE; i++) {
				memset((void *)pobTran, 0x00, sizeof(TRANSACTION_OBJECT));
				bytes = read(fhandle, (void *)pobTran, sizeof(TRANSACTION_OBJECT));
				if (bytes != sizeof(TRANSACTION_OBJECT)) {
					lseek(fhandle, (long)0, SEEK_SET);
					read(fhandle, (void *)pobTran, sizeof(TRANSACTION_OBJECT));
				}
				if (pobTran->Status==Status) break;
				if (Status==2 && pobTran->Status==3) break;
			}
		} 
	} while (1);
	close(fhandle);
	return 1;
}

int GetLastTransactionRecord(int Status, TRANSACTION_OBJECT *pobTran)
{  
	int fhandle;
	int bytes;
	int PrevRecordNo=0;
	int LastTrxRecNo = 0;

	fhandle = open("BATCH", O_RDWR);
	if (fhandle == -1) return 0;
	do {
		memset((void *)pobTran, 0x00, sizeof(TRANSACTION_OBJECT));
		bytes = read(fhandle, (void *)pobTran, sizeof(TRANSACTION_OBJECT));
		if (bytes == sizeof(TRANSACTION_OBJECT)){
			if (PrevRecordNo==0 || pobTran->RecordNo == PrevRecordNo+1) {
				PrevRecordNo = pobTran->RecordNo;
			} else {
				break;
			}
			if (pobTran->Status == Status) LastTrxRecNo = pobTran->RecordNo; 
			if (Status==2 && pobTran->Status == 3) LastTrxRecNo = pobTran->RecordNo; 
		}else{
			break;
		}
	}while (1);

	PrevRecordNo = LastTrxRecNo;

	if (PrevRecordNo == 0) {
	  lseek(fhandle, (long)0, SEEK_SET);
	} else if (PrevRecordNo % BATCH_SIZE){
	  lseek(fhandle, (long)(((PrevRecordNo % BATCH_SIZE)-1)*sizeof(TRANSACTION_OBJECT)), SEEK_SET);
	} else {
	  lseek(fhandle, (long)((BATCH_SIZE-1)*sizeof(TRANSACTION_OBJECT)), SEEK_SET);
	}
	bytes = read(fhandle, (void *)pobTran, sizeof(TRANSACTION_OBJECT));
	close(fhandle);	
	if (bytes != sizeof(TRANSACTION_OBJECT)) return 0;
	if (LastTrxRecNo==0) {
		DisplayStatus("No Batch Trxn!");
		SVC_WAIT(2000);
		return 0;
	}
	return 1;
}

int GetReversalTransactionRecord(TRANSACTION_OBJECT *pobTran)
{  
	int fhandle;
	int bytes;
	int found = 0;

	fhandle = open("BATCH", O_RDWR);
	if (fhandle == -1) return 0;
	do {
		memset((void *)pobTran, 0x00, sizeof(TRANSACTION_OBJECT));
		bytes = read(fhandle, (void *)pobTran, sizeof(TRANSACTION_OBJECT));
		if (bytes == sizeof(TRANSACTION_OBJECT)){
			if (pobTran->Status == 1 || pobTran->Status == 3) {  //reversal found
				found = 1;
				break;
			}
		}else{
			break;
		}
	}while (1);
	close(fhandle);	
	if (!found) return 2;
	return 1;
}

int SaveBatchRecord(TRANSACTION_OBJECT *pobTran)
{
	int fhandle;
	fhandle = open("BATCH", O_RDWR);
	if (fhandle == -1) return 0;
	if (pobTran->RecordNo % BATCH_SIZE){
	  lseek(fhandle, (long)(((pobTran->RecordNo % BATCH_SIZE)-1)*sizeof(TRANSACTION_OBJECT)), SEEK_SET);
	} else {
	  lseek(fhandle, (long)((BATCH_SIZE-1)*sizeof(TRANSACTION_OBJECT)), SEEK_SET);
	}
	write(fhandle, (void *)pobTran, sizeof(TRANSACTION_OBJECT));
	close(fhandle);
	return 1;
}

int SaveNewBatchRecord(TRANSACTION_OBJECT *pobTran)
{
	int fhandle;
	int bytes;
	int PrevRecordNo=0;
	char TimeBuff[20];
	TRANSACTION_OBJECT pobTranBuff, pobTranBuff2;

	fhandle = open("BATCH", O_RDWR);
	if (fhandle == -1) return 0;
	do {
		memset((void *)&pobTranBuff, 0x00, sizeof(TRANSACTION_OBJECT));
		bytes = read(fhandle, (void *)&pobTranBuff, sizeof(TRANSACTION_OBJECT));
		if (bytes == sizeof(TRANSACTION_OBJECT)){
			if (PrevRecordNo==0 || pobTranBuff.RecordNo == PrevRecordNo+1) {
				PrevRecordNo = pobTranBuff.RecordNo;
			} else {
				break;
			}
		}else{
			break;
		}
	}while (1);
	if (PrevRecordNo == 0) {
	  lseek(fhandle, (long)0, SEEK_SET);
	} else if (PrevRecordNo % BATCH_SIZE){
	  lseek(fhandle, (long)(((PrevRecordNo % BATCH_SIZE)-1)*sizeof(TRANSACTION_OBJECT)), SEEK_SET);
	} else {
	  lseek(fhandle, (long)((BATCH_SIZE-1)*sizeof(TRANSACTION_OBJECT)), SEEK_SET);
	}
	bytes = read(fhandle, (void *)&pobTranBuff, sizeof(TRANSACTION_OBJECT));
	memset(TimeBuff, 0x00, sizeof(TimeBuff));
	SVC_CLOCK(0, TimeBuff, 15);
	pobTran->RecordNo = pobTranBuff.RecordNo + 1;
	if (pobTran->RecordNo > MAX_RECNO) pobTran->RecordNo = 1;
	if (strncmp(pobTranBuff.szDate, &TimeBuff[2], 6)) {
		pobTran->STAN = 1;
	} else { 
		pobTran->STAN = pobTranBuff.STAN + 1;
	}
	strncpy(pobTran->szDate, &TimeBuff[2], 6);
	pobTran->szDate[6] = 0x00;
	strncpy(pobTran->szTime, &TimeBuff[8], 6);
	pobTran->szTime[6] = 0x00;
	pobTran->Status = 0;
	if (pobTran->RecordNo % BATCH_SIZE){
	  lseek(fhandle, (long)(((pobTran->RecordNo % BATCH_SIZE)-1)*sizeof(TRANSACTION_OBJECT)), SEEK_SET);
	} else {
	  lseek(fhandle, (long)((BATCH_SIZE-1)*sizeof(TRANSACTION_OBJECT)), SEEK_SET);
	}
	//HERE checking the reversal needed trx?
	memset((void *)&pobTranBuff2, 0x00, sizeof(TRANSACTION_OBJECT));
	bytes = read(fhandle, (void *)&pobTranBuff2, sizeof(TRANSACTION_OBJECT));
	if (pobTranBuff2.Status==1 || pobTranBuff2.Status==3) {
		DisplayStatus("Out of Memory");
		vdWarnBeep();
		DisplayStatus("Must Send Reversal!");
		SVC_WAIT(2000);
		return 0;
	}
	pobTran->lnInvNum = ulGetAndIncInvNum();
	if (pobTran->RecordNo % BATCH_SIZE){
	  lseek(fhandle, (long)(((pobTran->RecordNo % BATCH_SIZE)-1)*sizeof(TRANSACTION_OBJECT)), SEEK_SET);
	} else {
	  lseek(fhandle, (long)((BATCH_SIZE-1)*sizeof(TRANSACTION_OBJECT)), SEEK_SET);
	}
	write(fhandle, (void *)pobTran, sizeof(TRANSACTION_OBJECT));
	close(fhandle);
	//DisplayStatus("New Batch Saved");
	return 1;
}

int SaveBatchRecordForReversal(TRANSACTION_OBJECT *pobTran)
{
	if (pobTran->Status == 0) pobTran->Status =1;
	if (pobTran->Status == 2) pobTran->Status =3;
	return (SaveBatchRecord(pobTran));
}

int SaveBatchRecordAfterReversal(TRANSACTION_OBJECT *pobTran)
{
	if (pobTran->Status == 1) pobTran->Status =0;
	if (pobTran->Status == 3) pobTran->Status =2;
	return (SaveBatchRecord(pobTran));
}

int SaveBatchRecordAfterTrx(TRANSACTION_OBJECT *pobTran)
{
	int RetVal;
	int Status = pobTran->Status;
	if (!strcmp(pobTran->szRespCode, "00")) {
		if (pobTran->Status == 1) pobTran->Status =2;  //only reversal/sensitive msg that saved
		if (pobTran->Status == 3) pobTran->Status =4;	
		RetVal = SaveBatchRecord(pobTran);
	} else {
		if (pobTran->Status == 1) pobTran->Status =0;
		if (pobTran->Status == 3) pobTran->Status =2;	
		RetVal = SaveBatchRecord(pobTran);
	}
    if (RetVal<=0){
		DisplayStatus("Batch Update Error!");
		vdWarnBeep();
		pobTran->Status = Status;
		SaveBatchRecord(pobTran);
		SVC_WAIT(3000);
	}
	return RetVal;
}

int FindAndSendReversal(void)
{
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	TRANSACTION_OBJECT obTran;
	int Ret=0;
	int inCommBegin = 0;

	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));
	memset((char *)&obTran, 0x00, sizeof(obTran));
	
	Ret = GetReversalTransactionRecord(&obTran);
	if (Ret<=0) return 0;
	if ((obTran.Status != 1 && obTran.Status != 3) || Ret==2) return 1;  //no need reversal, continue transaction

	DisplayStatus("Send Reversal...");
	LOG_PRINTFF((0x08L, "FindAndSendReversal ... "));
	if (Ret>0) {
		if (obCommunication.fLinkUp != VS_TRUE) {
			if (obCommunication.inBegin) {
				if (obCommunication.inBegin(&obCommunication, 1 , VS_TRUE) < VS_SUCCESS) {
					DisplayStatus("Connection Failed!");
					LOG_PRINTFF((0x08L, "FindAndSendReversal ... CONNECTION FAIL"));
					Ret = 0;
				}
				Ret = 1;
				inCommBegin = 1;
			} else {
				LOG_PRINTFF((0x08L, "FindAndSendReversal ... NO COMM initialized"));
				Ret = 0;
			}
			if (Ret==1 && obCommunication.inCheck){
				if (obCommunication.inCheck(&obCommunication) != VS_SUCCESS){
					DisplayStatus("Not Connected!");
					LOG_PRINTFF((0x08L, "FindAndSendReversal ... NOT CONNECTED"));
					Ret = 0;
				}
				Ret = 1;
				inCommBegin = 1;
			} else {
				LOG_PRINTFF((0x08L, "FindAndSendReversal ... NO COMM initialized 2"));
				Ret = 0;
			}
		}
	}
	LOG_PRINTFF((0x08L, "FindAndSendReversal ... READY TO SEND REVERSAL"));
	if (Ret>0) Ret = SetBitmap(&obTran);
	if (Ret>0) Ret = PackMessage(&obTran, SentBuff);
	if (Ret>0) Ret = SendAndReceiveReversal(&obTran, SentBuff, RecvBuff);
	if (Ret>0) Ret = UnpackAndValidateMessage(&obTran, RecvBuff);
	if (Ret>0) Ret = inDisplayHostResponse(&obTran);
	//reversal will not consider successfull until approved by host
	if (Ret>0) {
		if (strcmp(obTran.szRespCode,"00")) {
			Ret = 0;
		}
	}
	////////
	if (Ret>0) Ret = SaveBatchRecordAfterReversal(&obTran);
	if (inCommBegin) {
		if (obCommunication.inEnd){
			if(obCommunication.inEnd(&obCommunication) != VS_SUCCESS){
				DisplayStatus("Error in disconnect!");
				//return 0;
			}
		}
	}
	LOG_PRINTFF((0x08L, "FindAndSendReversal ... END"));
	return Ret;
}


int SendAndReceiveReversal(TRANSACTION_OBJECT *pobTran, unsigned char *SentBuff, unsigned char *RecvBuff) 
{
    int inRetVal = 0;                               
	unsigned char buff[MSG_BUFF_SIZE+1];
	int SentSize = SentBuff[0]*256 + SentBuff[1];
	int RecvSize = 0;
	
	//SVC_WAIT(1000);
	memset(buff, 0x00, sizeof(buff));
	memcpy((char *)buff, (char *)SentBuff, SentSize+2);
	LOG_PRINTFF((0x08L, "inReqSiz is (%d-2)", SentSize+2));
	LOG_PRINT_HEX(buff, SentSize+2);

//#ifdef __arm
	if (fAES() && (obCommunication.inLinkType!=8)) { // encrypt data
		unsigned long ticks;
		unsigned char szSendBuffTmp[1024];
		int inSendSizeTmp = SentSize+2;
		int iRet;
		memset(szSendBuffTmp, 0x00, sizeof(szSendBuffTmp));
		memcpy(szSendBuffTmp, (char *)SentBuff, inSendSizeTmp);
		memset(SentBuff, 0x00, sizeof(SentBuff));
		ticks = read_ticks();
		iRet = inPvsAesEncrypt(szSendBuffTmp, inSendSizeTmp, SentBuff, &SentSize);
		memmove(&SentBuff[2], SentBuff, SentSize);
		SentBuff[0] = SentSize/256;
		SentBuff[1] = SentSize%256;
		//SendSize = SendSize + 2;
		LOG_PRINTFF((0x08L, "AES Encrypt Time Taken = [%ld ms]", read_ticks()-ticks));
		if (iRet != 0)
			return -1;  //encrypt err
	}
//#endif

    if (obCommunication.inSend) {
		if (obCommunication.inLinkType == 1 || obCommunication.inLinkType == 3 || obCommunication.inLinkType == 8 || obCommunication.inLinkType == 9)  {
			inRetVal = obCommunication.inSend(&obCommunication, (char *)&SentBuff[2], SentSize, VS_TRUE, inGetSendTimeOut() /*SEND_COMM_TIMEOUT*/, 0L);
		} else {
			SentSize = SentSize + 2;
			inRetVal = obCommunication.inSend(&obCommunication, (char *)SentBuff, SentSize, VS_TRUE, inGetSendTimeOut() /*SEND_COMM_TIMEOUT*/, 0L);            
		}
        if ((inRetVal == E_NOCARRIER) ||(inRetVal == E_X_NOCARRIER) || (inRetVal == VS_CARRIER)) {
			DisplayStatus("No Carrier!");
			return 0;
        }
		if (inRetVal != SentSize){
			DisplayStatus("Sending Message Fail!");        
			return 0;
        }
		if (inEnablePrintISOTrace()) {
			memset(buff, 0x00, sizeof(buff));
			memcpy((char *)buff, (char *)&SentBuff[2], SentSize);
			LOG_PRINT_RCPT("SND:");
			LOG_PRINT_RCPT_HEX(buff, SentSize);
		}
    }
    if (obCommunication.inReceive) {
		if (obCommunication.inLinkType == 1 || obCommunication.inLinkType == 3 || obCommunication.inLinkType == 8 || obCommunication.inLinkType == 9)  {
			inRetVal = obCommunication.inReceive(&obCommunication, (char *)&RecvBuff[2], MSG_BUFF_SIZE-3, inGetRecvTimeOut() /*RECV_COMM_TIMEOUT*/, 0L);
		} else {
			inRetVal = obCommunication.inReceive(&obCommunication, (char *)RecvBuff, MSG_BUFF_SIZE-3, inGetRecvTimeOut() /*RECV_COMM_TIMEOUT*/, 0L);
		}
		if (inRetVal>0) RecvSize = inRetVal;
	}
    if (obCommunication.inSendReceive) {
        inRetVal = obCommunication.inSendReceive((char *)&SentBuff[2], SentSize, (char *)&RecvBuff[2], &RecvSize);
	}
	//SVC_WAIT(1000);
	LOG_PRINTFF((0x08L, "inRetVal is (%d)", inRetVal));
	LOG_PRINTFF((0x08L, "RecvSize is (%d)", RecvSize));
    if((inRetVal == E_NOCARRIER) ||(inRetVal == E_X_NOCARRIER) || (inRetVal == VS_CARRIER)) {
		//DisplayStatus("Lost Carrier!");
    } else if (inRetVal <= 0 || inRetVal != RecvSize) {
		DisplayStatus("Com Error!");
    } else {
//#ifdef __arm
		if (fAES() && (obCommunication.inLinkType!=8) && (inRetVal>10)) { // decrypt data
			unsigned char szRecvBuffTmp[1024];
			int inRecvSizeTmp = inRetVal-2;
			int iRet;
			memset(szRecvBuffTmp, 0x00, sizeof(szRecvBuffTmp));
			memcpy(szRecvBuffTmp, &RecvBuff[2], inRecvSizeTmp);
			memset(RecvBuff, 0x00, sizeof(RecvBuff));	
			iRet = inPvsAesDecrypt(szRecvBuffTmp, inRecvSizeTmp, RecvBuff, &RecvSize);
			LOG_PRINTFF((0x08L, "[DECRYPTED (%d)]", RecvSize));
			LOG_PRINT_HEX((unsigned char *)RecvBuff, RecvSize);
			inRetVal = RecvSize;
			if (iRet != 0)
				return -1;  //decrypt err
		} 
//#endif
		if (obCommunication.inLinkType == 1 || obCommunication.inLinkType == 3 || obCommunication.inLinkType == 8 || obCommunication.inLinkType == 9)  { 
			RecvBuff[0] = (inRetVal) / 256;
			RecvBuff[1] = (inRetVal) % 256;
		} else {
			RecvBuff[0] = (inRetVal-2) / 256;  //temporary for BCD type host
			RecvBuff[1] = (inRetVal-2) % 256;
		}
		memset(buff, 0x00, sizeof(buff));
		memcpy((char *)buff, (char *)RecvBuff, RecvSize);
		LOG_PRINTFF((0x08L,     "inTxRx8583, NoOfBytes = %d", inRetVal));
		LOG_PRINT_HEX(buff, RecvSize);
		if (inEnablePrintISOTrace()) {
			memset(buff, 0x00, sizeof(buff));
			memcpy((char *)buff, (char *)&RecvBuff[2], RecvSize);
			LOG_PRINT_RCPT("RCV:");
			LOG_PRINT_RCPT_HEX(buff, RecvSize);
		}
	}
	return inRetVal;
}


int FindAndSendOffline(void)
{
/*
	unsigned char SentBuff[MSG_BUFF_SIZE + 1];
	unsigned char RecvBuff[MSG_BUFF_SIZE + 1];
	TRANSACTION_OBJECT obTran;
	int Ret;
	int inCommBegin = 0;

	memset(SentBuff, 0x00, sizeof(SentBuff));
	memset(RecvBuff, 0x00, sizeof(RecvBuff));
	memset((char *)&obTran, 0x00, sizeof(obTran));
	
	Ret = GetReversalTransactionRecord(&obTran);
	if (Ret<=0) return 0;
	if ((obTran.Status != 1 && obTran.Status != 3) || Ret==2) return 1;  //no need reversal, continue transaction

	DisplayStatus("Send Reversal...");
	if (obCommunication.fLinkUp != VS_TRUE) {
		if (obCommunication.inBegin) {
			if (obCommunication.inBegin(&obCommunication, 1 , VS_TRUE) < VS_SUCCESS) {
				DisplayStatus("Connection Failed!");
				return 0;
			}
		}
		if (obCommunication.inCheck){
			if (obCommunication.inCheck(&obCommunication) != VS_SUCCESS){
				DisplayStatus("Not Connected!");
				return 0;
			}
		}
	}
	if (SetBitmap(&obTran)<=0) return 0;
	if (PackMessage(&obTran, SentBuff)<=0) return 0;
	if (SendAndReceiveReversal(&obTran, SentBuff, RecvBuff)<=0) return 0;
	if (UnpackAndValidateMessage(&obTran, RecvBuff)<=0) return 0;
	if (inCommBegin) {
		if (obCommunication.inEnd){
			if(obCommunication.inEnd(&obCommunication) != VS_SUCCESS){
				DisplayStatus("Error in disconnect!");
				//return 0;
			}
		}
	}
	if (SaveBatchRecordAfterReversal(&obTran)<=0) return 0;
*/
	return 1;
}

void vdUpdateLnTotal(TRANSACTION_OBJECT *pobTran)
{
	char buff[30];
	memset(buff, 0x00, sizeof(buff));
	
	if (strlen(pobTran->szTotal)>=2) {
		strncpy(buff, pobTran->szTotal, strlen(pobTran->szTotal)-2);
	} 

	pobTran->Total = atol(buff);
}

void vdDisplayMerchantName(void)
{
	char hrf[20];
	char buff[128];

	memset(hrf, 0x00, sizeof(hrf));
	memset(buff, 0x00, sizeof(buff));

	get_env(PRT_HEADER1, buff, sizeof(buff)-1);
	vdTrimSpace(buff);
	if (strlen(buff)) vdFormatText(buff, 16, CENTERED);

	get_font(hrf);
	set_font("");
	gotoxy(1, 2);
	write_at("                           ", 21, 1, 2);
	set_font("F:asc4x16.vft");	
	if (strlen(buff)==16) {write_at(buff, 16, 1, 2);}
	else {display_at(1, 2, buff, CLR_EOL);}
	set_font(hrf);
	set_font("");
}

void vdGetTrxFee(char *buffer, TRANSACTION_OBJECT *pobTran)
{
	char buff[128];
	memset(buff, 0x00, sizeof(buff));

	if (pobTran->isOnUs==1) { 	
		if (pobTran->inOriginalCode == PMT_TRX_TRANSFER || pobTran->inOriginalCode == PMT_TRX_PURCHASE) {
			get_env_x(FEE, 0, buff);		
			if (atoi(buff)==0) {
				memset(buff, 0x00, sizeof(buff));
			} else {
				memset(buff, 0x00, sizeof(buff));
				get_env_x(FEE, 1, buff);
			}
		} else if (pobTran->inOriginalCode == PMT_TRX_TRANSFER_REK_LAIN) {
			get_env_x(FEE, 4, buff);		
			if (atoi(buff)==0) {
				memset(buff, 0x00, sizeof(buff));
			} else {
				memset(buff, 0x00, sizeof(buff));
				get_env_x(FEE, 5, buff);
			}
		} else if (pobTran->inOriginalCode == PMT_TRX_TRANSFER_BANK_LAIN) {
			get_env_x(FEE, 8, buff);		
			if (atoi(buff)==0) {
				memset(buff, 0x00, sizeof(buff));
			} else {
				memset(buff, 0x00, sizeof(buff));
				get_env_x(FEE, 9, buff);
			}
		}
	} else {
		if (pobTran->inOriginalCode == PMT_TRX_TRANSFER || pobTran->inOriginalCode == PMT_TRX_PURCHASE) {
			get_env_x(FEE, 0, buff);		
			if (atoi(buff)==2) {
				memset(buff, 0x00, sizeof(buff));
			} else {
				memset(buff, 0x00, sizeof(buff));
				get_env_x(FEE, 3, buff);
			}
		} else if (pobTran->inOriginalCode == PMT_TRX_TRANSFER_REK_LAIN) {
			get_env_x(FEE, 6, buff);		
			if (atoi(buff)==0) {
				memset(buff, 0x00, sizeof(buff));
			} else {
				memset(buff, 0x00, sizeof(buff));
				get_env_x(FEE, 7, buff);
			}
		} else if (pobTran->inOriginalCode == PMT_TRX_TRANSFER_BANK_LAIN) {
			get_env_x(FEE, 10, buff);		
			if (atoi(buff)==0) {
				memset(buff, 0x00, sizeof(buff));
			} else {
				memset(buff, 0x00, sizeof(buff));
				get_env_x(FEE, 11, buff);
			}
		}
	}

	if (strlen(buff)) {
		FormatNumberInd(buffer, buff);
	}
}

void vdDisplayFee(TRANSACTION_OBJECT *pobTran)
{
	char hrf[20];
	char buff[128];
	char buffer[128];

	memset(hrf, 0x00, sizeof(hrf));
	memset(buff, 0x00, sizeof(buff));
	memset(buffer, 0x00, sizeof(buffer));
	
	vdGetTrxFee(buffer, pobTran);

	if (strlen(buffer)==0) {
		//vdDisplayMerchantName();
		//vdScrollDisplay();
		return;
	}

	sprintf(buff, "BIAYA RP.%12s", buffer);
	get_font(hrf);
	set_font("");		

	vdScrollDisplay();
	display_at(1, 7, buff, CLR_EOL);
	vdScrollDisplay();
	display_at(1, 7, "  ATAU BIAYA SESUAI  ", CLR_EOL);
	vdDisplayMerchantName();
	vdScrollDisplay();
	display_at(1, 7, " KETENTUAN BANK ANDA ", CLR_EOL);

	set_font(hrf);
}

void vdDisplayFee2(TRANSACTION_OBJECT *pobTran)
{
	char hrf[30];

	if (pobTran->isOnUs==1) return;

	memset(hrf, 0x00, sizeof(hrf));

	get_font(hrf);
	set_font("");		
	vdScrollDisplay();
	display_at(1, 7, "BIAYA TRANSFER SESUAI", CLR_EOL);
	vdScrollDisplay();
	display_at(1, 7, " KETENTUAN BANK ANDA ", CLR_EOL);
	set_font(hrf);
}